module tests: add tests for coercedTo

+5
lib/tests/modules.sh
···
checkConfigError 'The option .* defined in .* does not exist.' "$@"
checkConfigOutput "true" "$@" ./define-module-check.nix
cat <<EOF
====== module tests ======
$pass Pass
···
checkConfigError 'The option .* defined in .* does not exist.' "$@"
checkConfigOutput "true" "$@" ./define-module-check.nix
+
# Check coerced value.
+
checkConfigOutput "\"42\"" config.value ./declare-coerced-value.nix
+
checkConfigOutput "\"24\"" config.value ./declare-coerced-value.nix ./define-value-string.nix
+
checkConfigError 'The option value .* in .* is not a coercedTo.' config.value ./declare-coerced-value.nix ./define-value-list.nix
+
cat <<EOF
====== module tests ======
$pass Pass
+10
lib/tests/modules/declare-coerced-value.nix
···
···
+
{ lib, ... }:
+
+
{
+
options = {
+
value = lib.mkOption {
+
default = 42;
+
type = lib.types.coercedTo lib.types.int builtins.toString lib.types.str;
+
};
+
};
+
}
+3
lib/tests/modules/define-value-list.nix
···
···
+
{
+
value = [];
+
}
+3
lib/tests/modules/define-value-string.nix
···
···
+
{
+
value = "24";
+
}