lol

lib/tests: Add tests for emptyValue

+45
+9
lib/tests/modules.sh
··· 284 284 checkConfigOutput '^"a y z"$' config.resultFooBar ./declare-variants.nix ./define-variant.nix 285 285 checkConfigOutput '^"a b c"$' config.resultFooFoo ./declare-variants.nix ./define-variant.nix 286 286 287 + ## emptyValue's 288 + checkConfigOutput "[ ]" config.list.a ./emptyValues.nix 289 + checkConfigOutput "{ }" config.attrs.a ./emptyValues.nix 290 + checkConfigOutput "null" config.null.a ./emptyValues.nix 291 + checkConfigOutput "{ }" config.submodule.a ./emptyValues.nix 292 + # These types don't have empty values 293 + checkConfigError 'The option .int.a. is used but not defined' config.int.a ./emptyValues.nix 294 + checkConfigError 'The option .nonEmptyList.a. is used but not defined' config.nonEmptyList.a ./emptyValues.nix 295 + 287 296 cat <<EOF 288 297 ====== module tests ====== 289 298 $pass Pass
+36
lib/tests/modules/emptyValues.nix
··· 1 + { lib, ... }: 2 + let 3 + inherit (lib) types; 4 + in { 5 + 6 + options = { 7 + int = lib.mkOption { 8 + type = types.lazyAttrsOf types.int; 9 + }; 10 + list = lib.mkOption { 11 + type = types.lazyAttrsOf (types.listOf types.int); 12 + }; 13 + nonEmptyList = lib.mkOption { 14 + type = types.lazyAttrsOf (types.nonEmptyListOf types.int); 15 + }; 16 + attrs = lib.mkOption { 17 + type = types.lazyAttrsOf (types.attrsOf types.int); 18 + }; 19 + null = lib.mkOption { 20 + type = types.lazyAttrsOf (types.nullOr types.int); 21 + }; 22 + submodule = lib.mkOption { 23 + type = types.lazyAttrsOf (types.submodule {}); 24 + }; 25 + }; 26 + 27 + config = { 28 + int.a = lib.mkIf false null; 29 + list.a = lib.mkIf false null; 30 + nonEmptyList.a = lib.mkIf false null; 31 + attrs.a = lib.mkIf false null; 32 + null.a = lib.mkIf false null; 33 + submodule.a = lib.mkIf false null; 34 + }; 35 + 36 + }