lib/tests/modules: Test functionTo submodule merging too

Changed files
+11 -8
lib
tests
modules
+2 -1
lib/tests/modules.sh
···
checkConfigError 'A definition for option .fun.\[function body\]. is not of type .string.. Definition values:\n\s*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix
checkConfigOutput '^"b a"$' config.result ./functionTo/list-order.nix
checkConfigOutput '^"a c"$' config.result ./functionTo/merging-attrs.nix
-
checkConfigOutput '^"fun.\[function body\].a fun.\[function body\].b"$' config.result ./functionTo/submodule-options.nix
# moduleType
checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix
···
checkConfigError 'A definition for option .fun.\[function body\]. is not of type .string.. Definition values:\n\s*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix
checkConfigOutput '^"b a"$' config.result ./functionTo/list-order.nix
checkConfigOutput '^"a c"$' config.result ./functionTo/merging-attrs.nix
+
checkConfigOutput '^"a bee"$' config.result ./functionTo/submodule-options.nix
+
checkConfigOutput '^"fun.\[function body\].a fun.\[function body\].b"$' config.optionsResult ./functionTo/submodule-options.nix
# moduleType
checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix
+9 -7
lib/tests/modules/functionTo/submodule-options.nix
···
options = {
fun = lib.mkOption {
type = types.functionTo (types.submodule {
-
options.a = lib.mkOption { };
});
};
};
···
options = {
fun = lib.mkOption {
type = types.functionTo (types.submodule {
-
options.b = lib.mkOption { };
});
};
};
···
result = lib.mkOption
{
type = types.str;
default = lib.concatStringsSep " "
(lib.concatLists
(lib.mapAttrsToList
···
config.fun = lib.mkMerge
[
-
(input: { inherit (input) a; })
-
(input: { inherit (input) b; })
-
(input: {
-
b = lib.mkForce input.c;
-
})
];
}
···
options = {
fun = lib.mkOption {
type = types.functionTo (types.submodule {
+
options.a = lib.mkOption { default = "a"; };
});
};
};
···
options = {
fun = lib.mkOption {
type = types.functionTo (types.submodule {
+
options.b = lib.mkOption { default = "b"; };
});
};
};
···
result = lib.mkOption
{
type = types.str;
+
default = lib.concatStringsSep " " (lib.attrValues (config.fun (throw "shouldn't use input param")));
+
};
+
+
optionsResult = lib.mkOption
+
{
+
type = types.str;
default = lib.concatStringsSep " "
(lib.concatLists
(lib.mapAttrsToList
···
config.fun = lib.mkMerge
[
+
(input: { b = "bee"; })
];
}