test(nix/readTree): test marking behavior of readTree

This ensures in a simple example that __readTree and __readTreeChildren
are populated correctly.

Change-Id: I69a46b2ddde0d1f9bf0dff1c4780f033ac8fc27a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3655
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
sterni 2021-09-30 14:46:12 +02:00
parent 348cf5ae73
commit 9dae5acf64
5 changed files with 35 additions and 0 deletions

View file

@ -97,8 +97,31 @@ let
# (depot.nix.readTree {} ./test-wrong-no-dots).no-dots-in-function)
];
read-markers = depot.nix.readTree {
path = ./test-marker;
args = {};
};
assertMarkerByPath = path:
assertEq "${lib.concatStringsSep "." path} is marked correctly"
(lib.getAttrFromPath path read-markers).__readTree path;
markers = it "marks nodes correctly" [
(assertMarkerByPath [ "directory-marked" ])
(assertMarkerByPath [ "directory-marked" "nested" ])
(assertMarkerByPath [ "file-children" "one" ])
(assertMarkerByPath [ "file-children" "two" ])
(assertEq "nix file children are marked correctly"
read-markers.file-children.__readTreeChildren [ "one" "two" ])
(assertEq "directory children are marked correctly"
read-markers.directory-marked.__readTreeChildren [ "nested" ])
(assertEq "absence of children is marked"
read-markers.directory-marked.nested.__readTreeChildren [ ])
];
in runTestsuite "readTree" [
example
traversal-logic
wrong
markers
]

View file

@ -0,0 +1,3 @@
{ ... }:
{}

View file

@ -0,0 +1,3 @@
{ ... }:
{}

View file

@ -0,0 +1,3 @@
{ ... }:
{}

View file

@ -0,0 +1,3 @@
{ ... }:
{}