c012f2f4ed
- [x] refactor lib into separate files, similar to NixOS/nixpkgs/lib. - [x] refactor ci to automatically generate derivations from flake outputs - [x] remove cluttered indirection statements throughout the codebase - [x] refactor hosts to allow for upcoming integration tests - [x] improve ambiguity in the existing docs - [x] add [BORS](https://bors.tech) support - [x] add initial integration test - [x] write tests documentation - [x] test lib - [x] improve version string generation, and do so automatically for pkgs/flake.nix sources Clean up the codebase as best we can in preparation for #152 and add tests. From now on, all PRs will be merged with BORS.
62 lines
1.3 KiB
Nix
62 lines
1.3 KiB
Nix
{ self, pkgs }:
|
|
let inherit (self.inputs.nixos) lib; in
|
|
with self.lib;
|
|
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 =
|
|
let testPaths = pkgs.runCommandNoCC "test-paths-in" { } ''
|
|
mkdir -p $out/{foo,bar,baz}
|
|
'';
|
|
in
|
|
{
|
|
expr = pathsIn testPaths;
|
|
|
|
expected = [
|
|
"${testPaths}/bar"
|
|
"${testPaths}/baz"
|
|
"${testPaths}/foo"
|
|
];
|
|
};
|
|
|
|
testPathsToImportedAttrs = {
|
|
expr =
|
|
pathsToImportedAttrs [
|
|
./testPathsToImportedAttrs/foo.nix
|
|
./testPathsToImportedAttrs/bar.nix
|
|
./testPathsToImportedAttrs/t.nix
|
|
./testPathsToImportedAttrs/f.nix
|
|
];
|
|
|
|
expected = {
|
|
foo = { bar = 1; };
|
|
bar = { foo = 2; };
|
|
t = true;
|
|
f = false;
|
|
};
|
|
};
|
|
}
|