diff options
Diffstat (limited to 'pkgs/populate/tests/default.nix')
| -rw-r--r-- | pkgs/populate/tests/default.nix | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkgs/populate/tests/default.nix b/pkgs/populate/tests/default.nix index e0ce469..9693034 100644 --- a/pkgs/populate/tests/default.nix +++ b/pkgs/populate/tests/default.nix @@ -114,7 +114,31 @@ let throw "tests: no scenario's name matches ${builtins.toJSON only}" else selected; + + # evalSource leaves out sources whose types are set to null, and refuses + # ones without exactly one type. + checkSourceTypes = let + inherit (populateLib) evalSource optionalSource; + names = source: lib.attrNames (evalSource source); + fails = source: + !(builtins.tryEval (builtins.deepSeq (evalSource source) null)).success; + in + names { + a.file = optionalSource false "/a"; + b.file = "/b"; + } == [ "b" ] && + names { + a.file = optionalSource false "/a"; + a.git = optionalSource true { url = "https://example.org/a"; ref = "main"; }; + } == [ "a" ] && + fails { a.file = lib.mkIf false "/a"; } && + fails { a = {}; } && + fails { a.file = "/a"; a.symlink = "b"; } || + throw "tests: evalSource doesn't leave out or refuse sources by their types as it should"; in + +assert checkSourceTypes; + testsOf false "" # Not built by nix-build either, which runs these scenarios anyway. // { |
