feat(nix/readTree): add tests of the README example
First step to slowly giving readTree some coverage, so we can do refactoring without breaking functionality. Change-Id: If25a8c0fa9c4ac7472c0473372f10a9326cccaf7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2465 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
5f9e9a60e8
commit
768f5ec301
7 changed files with 47 additions and 0 deletions
1
nix/readTree/tests/.skip-subtree
Normal file
1
nix/readTree/tests/.skip-subtree
Normal file
|
@ -0,0 +1 @@
|
||||||
|
These tests call their own readTree, so the toplevel one shouldn’t bother
|
37
nix/readTree/tests/default.nix
Normal file
37
nix/readTree/tests/default.nix
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{ depot, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (depot.nix.runTestsuite)
|
||||||
|
runTestsuite
|
||||||
|
it
|
||||||
|
assertEq
|
||||||
|
assertThrows
|
||||||
|
;
|
||||||
|
|
||||||
|
tree-ex = depot.nix.readTree {} ./test-example;
|
||||||
|
|
||||||
|
example = it "corresponds to the example" [
|
||||||
|
(assertEq "third_party attrset"
|
||||||
|
(lib.isAttrs tree-ex.third_party
|
||||||
|
&& (! lib.isDerivation tree-ex.third_party))
|
||||||
|
true)
|
||||||
|
(assertEq "third_party attrset other attribute"
|
||||||
|
tree-ex.third_party.favouriteColour
|
||||||
|
"orange")
|
||||||
|
(assertEq "rustpkgs attrset aho-corasick"
|
||||||
|
tree-ex.third_party.rustpkgs.aho-corasick
|
||||||
|
"aho-corasick")
|
||||||
|
(assertEq "rustpkgs attrset serde"
|
||||||
|
tree-ex.third_party.rustpkgs.serde
|
||||||
|
"serde")
|
||||||
|
(assertEq "tools cheddear"
|
||||||
|
"cheddar"
|
||||||
|
tree-ex.tools.cheddar)
|
||||||
|
(assertEq "tools roquefort"
|
||||||
|
tree-ex.tools.roquefort
|
||||||
|
"roquefort")
|
||||||
|
];
|
||||||
|
|
||||||
|
in runTestsuite "readTree" [
|
||||||
|
example
|
||||||
|
]
|
5
nix/readTree/tests/test-example/third_party/default.nix
vendored
Normal file
5
nix/readTree/tests/test-example/third_party/default.nix
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
favouriteColour = "orange";
|
||||||
|
}
|
1
nix/readTree/tests/test-example/third_party/rustpkgs/aho-corasick.nix
vendored
Normal file
1
nix/readTree/tests/test-example/third_party/rustpkgs/aho-corasick.nix
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ ... }: "aho-corasick"
|
1
nix/readTree/tests/test-example/third_party/rustpkgs/serde.nix
vendored
Normal file
1
nix/readTree/tests/test-example/third_party/rustpkgs/serde.nix
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ ... }: "serde"
|
|
@ -0,0 +1 @@
|
||||||
|
{ ... }: "cheddar"
|
1
nix/readTree/tests/test-example/tools/roquefort.nix
Normal file
1
nix/readTree/tests/test-example/tools/roquefort.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ ... }: "roquefort"
|
Loading…
Reference in a new issue