tests: additional tests for bugfix (#4354)

This commit is contained in:
Arkoniak
2025-08-13 10:13:46 +03:00
parent 5ac28f3947
commit 691e66a7fd
5 changed files with 49 additions and 0 deletions

View File

@ -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]") {
waybar::Config conf;
conf.load("test/config/include-multi.json");

View File

@ -0,0 +1,5 @@
{
"include": ["modules/*.jsonc"],
"position": "top",
"nullOption": null
}

View File

@ -0,0 +1,5 @@
{
"include": ["test/config/modules/*.jsonc"],
"position": "top",
"nullOption": null
}

View File

@ -0,0 +1,6 @@
{
"cpu": {
"interval": 2,
"format": "goo"
}
}

View File

@ -0,0 +1,6 @@
{
"memory": {
"interval": 2,
"format": "foo",
}
}