aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/libutil/config.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/libutil/config.cc')
-rw-r--r--tests/unit/libutil/config.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/unit/libutil/config.cc b/tests/unit/libutil/config.cc
index 1629969ba..1600f4ff0 100644
--- a/tests/unit/libutil/config.cc
+++ b/tests/unit/libutil/config.cc
@@ -1,5 +1,9 @@
#include "config.hh"
#include "args.hh"
+#include "file-system.hh"
+#include "environment-variables.hh"
+#include "logging.hh"
+#include "tests/test-data.hh"
#include <sstream>
#include <gtest/gtest.h>
@@ -287,6 +291,35 @@ namespace nix {
), Error);
}
+ TEST(Config, includeRelativePath) {
+ Config config;
+ Setting<std::string> setting{&config, "", "puppy", "description"};
+
+ config.applyConfig("include puppy.conf", {
+ .path = getUnitTestDataPath("nix.conf")
+ });
+
+ std::map<std::string, Config::SettingInfo> settings;
+ config.getSettings(settings);
+ ASSERT_FALSE(settings.empty());
+ ASSERT_EQ(settings["puppy"].value, "doggy");
+ }
+
+ TEST(Config, includeTildePath) {
+ Config config;
+ Setting<std::string> setting{&config, "", "puppy", "description"};
+
+ config.applyConfig("include ~/puppy.conf", {
+ .path = "/doesnt-exist",
+ .home = getUnitTestData()
+ });
+
+ std::map<std::string, Config::SettingInfo> settings;
+ config.getSettings(settings);
+ ASSERT_FALSE(settings.empty());
+ ASSERT_EQ(settings["puppy"].value, "doggy");
+ }
+
TEST(Config, applyConfigInvalidThrows) {
Config config;
ASSERT_THROW(config.applyConfig("value == key"), UsageError);