lib/types: Add coercedTo unsound tests
This commit is contained in:
parent
ef8996f15e
commit
b16a69289a
|
@ -138,6 +138,11 @@ checkConfigOutput "\"42\"" config.value ./declare-coerced-value.nix
|
||||||
checkConfigOutput "\"24\"" config.value ./declare-coerced-value.nix ./define-value-string.nix
|
checkConfigOutput "\"24\"" config.value ./declare-coerced-value.nix ./define-value-string.nix
|
||||||
checkConfigError 'The option value .* in .* is not.*string or signed integer.*' config.value ./declare-coerced-value.nix ./define-value-list.nix
|
checkConfigError 'The option value .* in .* is not.*string or signed integer.*' config.value ./declare-coerced-value.nix ./define-value-list.nix
|
||||||
|
|
||||||
|
# Check coerced value with unsound coercion
|
||||||
|
checkConfigOutput "12" config.value ./declare-coerced-value-unsound.nix
|
||||||
|
checkConfigError 'The option value .* in .* is not.*8 bit signed integer.* or string.*' config.value ./declare-coerced-value-unsound.nix ./define-value-string-bigint.nix
|
||||||
|
checkConfigError 'unrecognised JSON value' config.value ./declare-coerced-value-unsound.nix ./define-value-string-arbitrary.nix
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
====== module tests ======
|
====== module tests ======
|
||||||
$pass Pass
|
$pass Pass
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
value = lib.mkOption {
|
||||||
|
default = "12";
|
||||||
|
type = lib.types.coercedTo lib.types.str lib.toInt lib.types.ints.s8;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
value = "foobar";
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
value = "1000";
|
||||||
|
}
|
Loading…
Reference in New Issue