3
0
Fork 0
forked from mirrors/nixpkgs

lib/tests/modules: add a test for the functionTo type

This commit is contained in:
Bas van Dijk 2018-08-07 18:44:58 +02:00
parent 7ed41ff5e7
commit 478af112e8
2 changed files with 32 additions and 0 deletions

View file

@ -149,6 +149,9 @@ checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-long-list.ni
# Check loaOf with many merges of lists.
checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-many-list-merges.nix
# Check the merge behaviour of the functionTo type.
checkConfigOutput "a b" config.result ./functionTo.nix
cat <<EOF
====== module tests ======
$pass Pass

View file

@ -0,0 +1,29 @@
{ lib, config, ... }:
with lib;
{
options = {
selector = mkOption {
default = _pkgs : [];
type = with types; functionTo (listOf str);
description = ''
Some descriptive text
'';
};
result = mkOption {
type = types.str;
default = toString (config.selector {
a = "a";
b = "b";
c = "c";
});
};
};
config = lib.mkMerge [
{ selector = pkgs: [ pkgs.a ]; }
{ selector = pkgs: [ pkgs.b ]; }
];
}