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

(cherry picked from commit 478af112e83df806bd8a51174834d2a130fbdeb9)
wip/yesman
Bas van Dijk 6 years ago committed by Silvan Mosberger
parent b454af298d
commit 43243539b3
No known key found for this signature in database
GPG Key ID: E8F1E9EAD284E17D
  1. 3
      lib/tests/modules.sh
  2. 29
      lib/tests/modules/functionTo.nix

@ -262,6 +262,9 @@ checkConfigOutput true config.value.mkbefore ./types-anything/mk-mods.nix
checkConfigOutput 1 config.value.nested.foo ./types-anything/mk-mods.nix
checkConfigOutput baz config.value.nested.bar.baz ./types-anything/mk-mods.nix
# Check the merge behaviour of the functionTo type.
checkConfigOutput "a b" config.result ./functionTo.nix
cat <<EOF
====== module tests ======
$pass Pass

@ -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…
Cancel
Save