tests: additional tests for bugfix (#4354)
This commit is contained in:
@ -84,6 +84,33 @@ TEST_CASE("Load simple config with include", "[config]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Load simple config with wildcard include", "[config]") {
|
||||||
|
waybar::Config conf;
|
||||||
|
conf.load("test/config/include-wildcard.json");
|
||||||
|
|
||||||
|
auto& data = conf.getConfig();
|
||||||
|
SECTION("validate cpu include file") { REQUIRE(data["cpu"]["format"].asString() == "goo"); }
|
||||||
|
SECTION("validate memory include file") { REQUIRE(data["memory"]["format"].asString() == "foo"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Load config using relative paths and wildcards", "[config]") {
|
||||||
|
waybar::Config conf;
|
||||||
|
|
||||||
|
const char* old_config_path = std::getenv(waybar::Config::CONFIG_PATH_ENV);
|
||||||
|
setenv(waybar::Config::CONFIG_PATH_ENV, "test/config", 1);
|
||||||
|
|
||||||
|
conf.load("test/config/include-relative-path.json");
|
||||||
|
|
||||||
|
auto& data = conf.getConfig();
|
||||||
|
SECTION("validate cpu include file") { REQUIRE(data["cpu"]["format"].asString() == "goo"); }
|
||||||
|
SECTION("validate memory include file") { REQUIRE(data["memory"]["format"].asString() == "foo"); }
|
||||||
|
|
||||||
|
if (old_config_path)
|
||||||
|
setenv(waybar::Config::CONFIG_PATH_ENV, old_config_path, 1);
|
||||||
|
else
|
||||||
|
unsetenv(waybar::Config::CONFIG_PATH_ENV);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Load multiple bar config with include", "[config]") {
|
TEST_CASE("Load multiple bar config with include", "[config]") {
|
||||||
waybar::Config conf;
|
waybar::Config conf;
|
||||||
conf.load("test/config/include-multi.json");
|
conf.load("test/config/include-multi.json");
|
||||||
|
5
test/config/include-relative-path.json
Normal file
5
test/config/include-relative-path.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"include": ["modules/*.jsonc"],
|
||||||
|
"position": "top",
|
||||||
|
"nullOption": null
|
||||||
|
}
|
5
test/config/include-wildcard.json
Normal file
5
test/config/include-wildcard.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"include": ["test/config/modules/*.jsonc"],
|
||||||
|
"position": "top",
|
||||||
|
"nullOption": null
|
||||||
|
}
|
6
test/config/modules/cpu.jsonc
Normal file
6
test/config/modules/cpu.jsonc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cpu": {
|
||||||
|
"interval": 2,
|
||||||
|
"format": "goo"
|
||||||
|
}
|
||||||
|
}
|
6
test/config/modules/memory.jsonc
Normal file
6
test/config/modules/memory.jsonc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"memory": {
|
||||||
|
"interval": 2,
|
||||||
|
"format": "foo",
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user