aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Turner <rbt@sent.as>2024-08-25 11:58:10 -0700
committerRebecca Turner <rbt@sent.as>2024-08-25 15:54:22 -0700
commit5fc6fcb31035f79a8e590f07d73dc6cc592e9e29 (patch)
treea47f804e3b3d74688e1dab6b6fd952664e0ef88b /tests
parentb6884388a1281d70bb4e5bb12e1cadd34bb832f0 (diff)
Thread `ApplyConfigOptions` through config parsing
This makes no changes to logic but makes the `ApplyConfigOptions` value available to consumers. Change-Id: I88cf53d38faac8472c556aee55c13d0acbd1e5db
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/libutil/config.cc2
-rw-r--r--tests/unit/libutil/paths-setting.cc42
2 files changed, 14 insertions, 30 deletions
diff --git a/tests/unit/libutil/config.cc b/tests/unit/libutil/config.cc
index 886e70da5..1629969ba 100644
--- a/tests/unit/libutil/config.cc
+++ b/tests/unit/libutil/config.cc
@@ -80,7 +80,7 @@ namespace nix {
class TestSetting : public AbstractSetting {
public:
TestSetting() : AbstractSetting("test", "test", {}) {}
- void set(const std::string & value, bool append) override {}
+ void set(const std::string & value, bool append, const ApplyConfigOptions & options) override {}
std::string to_string() const override { return {}; }
bool isAppendable() override { return false; }
};
diff --git a/tests/unit/libutil/paths-setting.cc b/tests/unit/libutil/paths-setting.cc
index 17cb125c8..c198b25e0 100644
--- a/tests/unit/libutil/paths-setting.cc
+++ b/tests/unit/libutil/paths-setting.cc
@@ -11,14 +11,13 @@ namespace nix {
class PathsSettingTestConfig : public Config
{
public:
- PathsSettingTestConfig()
- : Config()
- { }
+ PathsSettingTestConfig() : Config() {}
PathsSetting<Paths> paths{this, Paths(), "paths", "documentation"};
};
-struct PathsSettingTest : public ::testing::Test {
+struct PathsSettingTest : public ::testing::Test
+{
public:
PathsSettingTestConfig mkConfig()
{
@@ -26,33 +25,27 @@ public:
}
};
-TEST_F(PathsSettingTest, parse) {
+TEST_F(PathsSettingTest, parse)
+{
auto config = mkConfig();
// Not an absolute path:
- ASSERT_THROW(config.paths.parse("puppy.nix"), Error);
+ ASSERT_THROW(config.paths.parse("puppy.nix", {}), Error);
- ASSERT_THAT(
- config.paths.parse("/puppy.nix"),
- Eq<Paths>({"/puppy.nix"})
- );
+ ASSERT_THAT(config.paths.parse("/puppy.nix", {}), Eq<Paths>({"/puppy.nix"}));
// Splits on whitespace:
ASSERT_THAT(
- config.paths.parse("/puppy.nix /doggy.nix"),
- Eq<Paths>({"/puppy.nix", "/doggy.nix"})
+ config.paths.parse("/puppy.nix /doggy.nix", {}), Eq<Paths>({"/puppy.nix", "/doggy.nix"})
);
// Splits on _any_ whitespace:
ASSERT_THAT(
- config.paths.parse("/puppy.nix \t /doggy.nix\n\n\n/borzoi.nix\r/goldie.nix"),
+ config.paths.parse("/puppy.nix \t /doggy.nix\n\n\n/borzoi.nix\r/goldie.nix", {}),
Eq<Paths>({"/puppy.nix", "/doggy.nix", "/borzoi.nix", "/goldie.nix"})
);
// Canonicizes paths:
- ASSERT_THAT(
- config.paths.parse("/puppy/../doggy.nix"),
- Eq<Paths>({"/doggy.nix"})
- );
+ ASSERT_THAT(config.paths.parse("/puppy/../doggy.nix", {}), Eq<Paths>({"/doggy.nix"}));
}
TEST_F(PathsSettingTest, append) {
@@ -61,26 +54,17 @@ TEST_F(PathsSettingTest, append) {
ASSERT_TRUE(config.paths.isAppendable());
// Starts with no paths:
- ASSERT_THAT(
- config.paths.get(),
- Eq<Paths>({})
- );
+ ASSERT_THAT(config.paths.get(), Eq<Paths>({}));
// Can append a path:
config.paths.set("/puppy.nix", true);
- ASSERT_THAT(
- config.paths.get(),
- Eq<Paths>({"/puppy.nix"})
- );
+ ASSERT_THAT(config.paths.get(), Eq<Paths>({"/puppy.nix"}));
// Can append multiple paths:
config.paths.set("/silly.nix /doggy.nix", true);
- ASSERT_THAT(
- config.paths.get(),
- Eq<Paths>({"/puppy.nix", "/silly.nix", "/doggy.nix"})
- );
+ ASSERT_THAT(config.paths.get(), Eq<Paths>({"/puppy.nix", "/silly.nix", "/doggy.nix"}));
}
} // namespace nix