-
Notifications
You must be signed in to change notification settings - Fork 0
/
filterOptions-check.nix
49 lines (43 loc) · 1.1 KB
/
filterOptions-check.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
lib @ {
assertMsg,
debug,
hasPrefix,
mkOption,
elem,
...
}: let
subject = import ./filterOptions.nix lib;
tests.testEmpty = {
expr = subject (p: o: true) {};
expected = {};
};
tests.testNoFilter = {
expr = subject (p: o: true) {foo-1 = mkOption {};};
expected = {foo-1 = mkOption {};};
};
tests.testFilter = {
expr = subject (p: o: hasPrefix "foo-" o.description) {
foo-1 = mkOption {description = "foo-1";};
bar-1 = mkOption {description = "bar-1";};
};
expected = {
foo-1 = mkOption {description = "foo-1";};
};
};
tests.testFilterDeep = {
expr = subject (p: o: o.description == "foo") {
nested.foo = mkOption {description = "foo";};
nested.bar = mkOption {description = "bar";};
};
expected.nested.foo = mkOption {description = "foo";};
};
tests.testFilterPath = {
expr = subject (p: o: elem "foo" p) {
nested.foo = mkOption {};
nested.bar = mkOption {};
};
expected.nested.foo = mkOption {};
};
failures = debug.runTests tests;
in
assertMsg (failures == []) (builtins.toJSON failures)