lib: add generator functions for toJSON & toYAML

They both reference the toJSON builtin, so we get semantic identifiers
that express the intent of the generation.
Both should be able to map each nix value (minus functions) to the
destination config files.

Includes two invocation unit tests.
This commit is contained in:
Profpatsch
2016-11-06 14:14:24 +01:00
parent 61311665cb
commit 26eb10e771
2 changed files with 38 additions and 1 deletions

View File

@@ -181,4 +181,27 @@ runTests {
'';
};
/* right now only invocation check */
testToJSONSimple =
let val = {
foobar = [ "baz" 1 2 3 ];
};
in {
expr = generators.toJSON {} val;
# trival implementation
expected = builtins.toJSON val;
};
/* right now only invocation check */
testToYAMLSimple =
let val = {
list = [ { one = 1; } { two = 2; } ];
all = 42;
};
in {
expr = generators.toYAML {} val;
# trival implementation
expected = builtins.toJSON val;
};
}