lib/generators: add toKeyValue & mkKeyValueLine (#20903)

generators for the common use case of simple config files which hold keys and
values. Used in the implementation for toINI.
This commit is contained in:
Profpatsch
2016-12-04 22:11:24 +01:00
committed by GitHub
parent 2f861e6ba6
commit ea412cd5a1
2 changed files with 41 additions and 4 deletions

View File

@@ -135,6 +135,22 @@ runTests {
# these tests assume attributes are converted to lists
# in alphabetical order
testMkKeyValueLine = {
expr = generators.mkKeyValueLine ":" "f:oo" "bar";
expected = ''f\:oo:bar'';
};
testToKeyValue = {
expr = generators.toKeyValue {} {
key = "value";
"other=key" = "baz";
};
expected = ''
key=value
other\=key=baz
'';
};
testToINIEmpty = {
expr = generators.toINI {} {};
expected = "";