forked from mirrors/nixpkgs
lib/tests/modules: add a test for the functionTo type
This commit is contained in:
parent
7ed41ff5e7
commit
478af112e8
|
@ -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
|
||||
|
|
29
lib/tests/modules/functionTo.nix
Normal file
29
lib/tests/modules/functionTo.nix
Normal 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 ]; }
|
||||
];
|
||||
}
|
Loading…
Reference in a new issue