diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2023-04-17 11:18:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-17 11:18:11 +0200 |
commit | 36a473c5e80957fc0f2fd398cb75053f635e4524 (patch) | |
tree | f80527413bfdbc72ff9a0f69af10d91b94dbe048 /src/libutil/tests/config.cc | |
parent | ab228d73db31ba854faca3d6264817551bcfd4c5 (diff) | |
parent | 9800c1e8074d248f75ea9bed1b5a0f76e799863d (diff) |
Merge pull request #8196 from obsidiansystems/fix-8162
Mark experimental configuration settings programmatically
Diffstat (limited to 'src/libutil/tests/config.cc')
-rw-r--r-- | src/libutil/tests/config.cc | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/src/libutil/tests/config.cc b/src/libutil/tests/config.cc index 8be6730dd..f250e934e 100644 --- a/src/libutil/tests/config.cc +++ b/src/libutil/tests/config.cc @@ -156,12 +156,54 @@ namespace nix { } TEST(Config, toJSONOnNonEmptyConfig) { + using nlohmann::literals::operator "" _json; Config config; - std::map<std::string, Config::SettingInfo> settings; - Setting<std::string> setting{&config, "", "name-of-the-setting", "description"}; + Setting<std::string> setting{ + &config, + "", + "name-of-the-setting", + "description", + }; + setting.assign("value"); + + ASSERT_EQ(config.toJSON(), + R"#({ + "name-of-the-setting": { + "aliases": [], + "defaultValue": "", + "description": "description\n", + "documentDefault": true, + "value": "value", + "experimentalFeature": null + } + })#"_json); + } + + TEST(Config, toJSONOnNonEmptyConfigWithExperimentalSetting) { + using nlohmann::literals::operator "" _json; + Config config; + Setting<std::string> setting{ + &config, + "", + "name-of-the-setting", + "description", + {}, + true, + Xp::Flakes, + }; setting.assign("value"); - ASSERT_EQ(config.toJSON().dump(), R"#({"name-of-the-setting":{"aliases":[],"defaultValue":"","description":"description\n","documentDefault":true,"value":"value"}})#"); + ASSERT_EQ(config.toJSON(), + R"#({ + "name-of-the-setting": { + "aliases": [], + "defaultValue": "", + "description": "description\n", + "documentDefault": true, + "value": "value", + "experimentalFeature": "flakes" + } + })#"_json); } TEST(Config, setSettingAlias) { |