tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
lib/tests: Add tests for emptyValue
Silvan Mosberger
4 years ago
b333395b
38228902
+45
2 changed files
expand all
collapse all
unified
split
lib
tests
modules
emptyValues.nix
modules.sh
+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
287
+
## emptyValue's
288
288
+
checkConfigOutput "[ ]" config.list.a ./emptyValues.nix
289
289
+
checkConfigOutput "{ }" config.attrs.a ./emptyValues.nix
290
290
+
checkConfigOutput "null" config.null.a ./emptyValues.nix
291
291
+
checkConfigOutput "{ }" config.submodule.a ./emptyValues.nix
292
292
+
# These types don't have empty values
293
293
+
checkConfigError 'The option .int.a. is used but not defined' config.int.a ./emptyValues.nix
294
294
+
checkConfigError 'The option .nonEmptyList.a. is used but not defined' config.nonEmptyList.a ./emptyValues.nix
295
295
+
287
296
cat <<EOF
288
297
====== module tests ======
289
298
$pass Pass
+36
lib/tests/modules/emptyValues.nix
···
1
1
+
{ lib, ... }:
2
2
+
let
3
3
+
inherit (lib) types;
4
4
+
in {
5
5
+
6
6
+
options = {
7
7
+
int = lib.mkOption {
8
8
+
type = types.lazyAttrsOf types.int;
9
9
+
};
10
10
+
list = lib.mkOption {
11
11
+
type = types.lazyAttrsOf (types.listOf types.int);
12
12
+
};
13
13
+
nonEmptyList = lib.mkOption {
14
14
+
type = types.lazyAttrsOf (types.nonEmptyListOf types.int);
15
15
+
};
16
16
+
attrs = lib.mkOption {
17
17
+
type = types.lazyAttrsOf (types.attrsOf types.int);
18
18
+
};
19
19
+
null = lib.mkOption {
20
20
+
type = types.lazyAttrsOf (types.nullOr types.int);
21
21
+
};
22
22
+
submodule = lib.mkOption {
23
23
+
type = types.lazyAttrsOf (types.submodule {});
24
24
+
};
25
25
+
};
26
26
+
27
27
+
config = {
28
28
+
int.a = lib.mkIf false null;
29
29
+
list.a = lib.mkIf false null;
30
30
+
nonEmptyList.a = lib.mkIf false null;
31
31
+
attrs.a = lib.mkIf false null;
32
32
+
null.a = lib.mkIf false null;
33
33
+
submodule.a = lib.mkIf false null;
34
34
+
};
35
35
+
36
36
+
}