diff options
author | Profpatsch <mail@profpatsch.de> | 2016-11-06 14:14:24 +0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2016-11-17 23:16:24 +0100 |
commit | 26eb10e771c2e7abdfe79d7f3db472af2e56a9fd (patch) | |
tree | ae0e1d736fb4f6a20c593d5ce94434a36dd301a6 /lib/tests.nix | |
parent | 61311665cb0f11c4688fc0013d732d85bbd66fca (diff) | |
download | nixpkgs-26eb10e771c2e7abdfe79d7f3db472af2e56a9fd.tar nixpkgs-26eb10e771c2e7abdfe79d7f3db472af2e56a9fd.tar.gz nixpkgs-26eb10e771c2e7abdfe79d7f3db472af2e56a9fd.tar.bz2 nixpkgs-26eb10e771c2e7abdfe79d7f3db472af2e56a9fd.tar.lz nixpkgs-26eb10e771c2e7abdfe79d7f3db472af2e56a9fd.tar.xz nixpkgs-26eb10e771c2e7abdfe79d7f3db472af2e56a9fd.tar.zst nixpkgs-26eb10e771c2e7abdfe79d7f3db472af2e56a9fd.zip |
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.
Diffstat (limited to 'lib/tests.nix')
-rw-r--r-- | lib/tests.nix | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/tests.nix b/lib/tests.nix index b5513dcb5ff..d59814987ed 100644 --- a/lib/tests.nix +++ b/lib/tests.nix @@ -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; + }; + } |