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:
Profpatsch 2021-01-30 07:03:20 +01:00
parent 5f9e9a60e8
commit 768f5ec301
7 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1 @@
These tests call their own readTree, so the toplevel one shouldnt bother

View 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
]

View file

@ -0,0 +1,5 @@
{ ... }:
{
favouriteColour = "orange";
}

View file

@ -0,0 +1 @@
{ ... }: "aho-corasick"

View file

@ -0,0 +1 @@
{ ... }: "serde"

View file

@ -0,0 +1 @@
{ ... }: "cheddar"

View file

@ -0,0 +1 @@
{ ... }: "roquefort"