summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBas van Dijk <v.dijk.bas@gmail.com>2018-08-07 18:44:58 +0200
committerSilvan Mosberger <contact@infinisil.com>2021-01-24 16:56:45 +0100
commit43243539b33d8fb0b2d14a3f9b79d6b641b74e2c (patch)
tree3e36003813c56b66f21c6eb9b8ee66f1057881fd /lib
parentb454af298d0511f43564c5ba2c2b9576bffc025a (diff)
lib/tests/modules: add a test for the functionTo type
(cherry picked from commit 478af112e83df806bd8a51174834d2a130fbdeb9)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/tests/modules.sh3
-rw-r--r--lib/tests/modules/functionTo.nix29
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index 309c5311361c..2d3a696e980a 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -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
diff --git a/lib/tests/modules/functionTo.nix b/lib/tests/modules/functionTo.nix
new file mode 100644
index 000000000000..591d9a47f93d
--- /dev/null
+++ b/lib/tests/modules/functionTo.nix
@@ -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 ]; }
+ ];
+}