2021-04-02 04:10:24 +02:00
|
|
|
{ pkgs, lib }:
|
|
|
|
with lib;
|
2021-04-18 02:30:55 +02:00
|
|
|
lib.runTests {
|
|
|
|
testConcatAttrs = {
|
|
|
|
expr = concatAttrs [{ foo = 1; } { bar = 2; } { baz = 3; }];
|
|
|
|
|
|
|
|
expected = { foo = 1; bar = 2; baz = 3; };
|
|
|
|
};
|
|
|
|
|
|
|
|
testGenAttrs' = {
|
|
|
|
expr = genAttrs'
|
|
|
|
[ "/foo/bar" "/baz/buzz" ]
|
|
|
|
(path: {
|
|
|
|
name = baseNameOf path;
|
|
|
|
value = "${path}/fizz";
|
|
|
|
});
|
|
|
|
|
|
|
|
expected = { bar = "/foo/bar/fizz"; buzz = "/baz/buzz/fizz"; };
|
|
|
|
};
|
|
|
|
|
|
|
|
testMapFilterAttrs = {
|
|
|
|
expr = mapFilterAttrs
|
|
|
|
(n: v: n == "foobar" && v == 1)
|
|
|
|
(n: v: lib.nameValuePair ("${n}bar") (v + 1))
|
|
|
|
{ foo = 0; bar = 2; };
|
|
|
|
|
|
|
|
expected = { foobar = 1; };
|
|
|
|
};
|
|
|
|
|
|
|
|
testPathsIn = {
|
|
|
|
expr = pathsIn (toString ./testPathsIn);
|
|
|
|
|
|
|
|
expected = map toString [
|
|
|
|
./testPathsIn/bar
|
|
|
|
./testPathsIn/baz
|
|
|
|
./testPathsIn/foo
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
testRgxToString = lib.testAllTrue [
|
|
|
|
(rgxToString ".+x" "vxk" == "vx")
|
|
|
|
(rgxToString "^fo" "foo" == "fo")
|
|
|
|
(rgxToString "a?" "a" == "a")
|
|
|
|
(rgxToString "hat" "foohatbar" == "hat")
|
|
|
|
];
|
|
|
|
|
|
|
|
testSafeReadDir = {
|
|
|
|
expr = safeReadDir ./profiles // safeReadDir ./nonexistentdir;
|
|
|
|
expected = {
|
|
|
|
foo = "directory";
|
|
|
|
t = "directory";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-04-26 22:30:10 +02:00
|
|
|
testSuites = {
|
2021-05-02 02:49:04 +02:00
|
|
|
expr = mkSuites {
|
2021-04-26 22:30:10 +02:00
|
|
|
suites = { profiles, ... }: with profiles; {
|
|
|
|
bar = [ foo ];
|
2021-04-18 02:30:55 +02:00
|
|
|
};
|
2021-04-26 22:30:10 +02:00
|
|
|
profiles = [ (./profiles) ];
|
2021-04-18 02:30:55 +02:00
|
|
|
};
|
2021-04-26 22:30:10 +02:00
|
|
|
expected = {
|
|
|
|
bar = [ (toString ./profiles/foo) ];
|
|
|
|
allProfiles = [
|
|
|
|
(toString ./profiles/foo)
|
|
|
|
(toString ./profiles/t)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2021-04-18 02:30:55 +02:00
|
|
|
}
|