test: multi-bar config with includes

This commit is contained in:
Aleksei Bavshin 2021-08-16 21:11:46 +07:00
parent 9f3b34e4d9
commit 8912bd3ed0
No known key found for this signature in database
GPG Key ID: 4F071603387A382A
7 changed files with 93 additions and 0 deletions

View File

@ -76,3 +76,37 @@ TEST_CASE("Load simple config with include", "[config]") {
REQUIRE(configs.empty());
}
}
TEST_CASE("Load multiple bar config with include", "[config]") {
waybar::Config conf;
conf.load("test/config/include-multi.json");
SECTION("bar config with sole include") {
auto data = conf.getOutputConfigs("OUT-0", "Fake ouptut #0");
REQUIRE(data.size() == 1);
REQUIRE(data[0]["height"].asInt() == 20);
}
SECTION("bar config with output and include") {
auto data = conf.getOutputConfigs("OUT-1", "Fake output #1");
REQUIRE(data.size() == 1);
REQUIRE(data[0]["height"].asInt() == 21);
}
SECTION("bar config with output override") {
auto data = conf.getOutputConfigs("OUT-2", "Fake output #2");
REQUIRE(data.size() == 1);
REQUIRE(data[0]["height"].asInt() == 22);
}
SECTION("multiple levels of include") {
auto data = conf.getOutputConfigs("OUT-3", "Fake output #3");
REQUIRE(data.size() == 1);
REQUIRE(data[0]["height"].asInt() == 23);
}
auto& data = conf.getConfig();
REQUIRE(data.isArray());
REQUIRE(data.size() == 4);
REQUIRE(data[0]["output"].asString() == "OUT-0");
}

View File

@ -0,0 +1,9 @@
[
{
"output": "OUT-0",
"height": 20
},
{},
{},
{}
]

View File

@ -0,0 +1,8 @@
[
{},
{
"height": 21
},
{},
{}
]

View File

@ -0,0 +1,9 @@
[
{},
{},
{
"output": "OUT-1",
"height": 22
},
{}
]

View File

@ -0,0 +1,8 @@
[
{},
{},
{},
{
"height": 23
}
]

View File

@ -0,0 +1,9 @@
[
{},
{},
{},
{
"output": "OUT-3",
"include": "test/config/include-multi-3-0.json"
}
]

View File

@ -0,0 +1,16 @@
[
{
"include": "test/config/include-multi-0.json"
},
{
"output": "OUT-1",
"include": "test/config/include-multi-1.json"
},
{
"output": "OUT-2",
"include": "test/config/include-multi-2.json"
},
{
"include": "test/config/include-multi-3.json"
}
]