diff options
author | sterni <sternenseemann@systemli.org> | 2021-09-30T12·46+0200 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2021-10-05T13·25+0000 |
commit | 9dae5acf6440dce30d61e8c3588f703088a64b0a (patch) | |
tree | a286be96c11bcd1fcebbe7e7533cebd5b84adce0 /nix | |
parent | 348cf5ae73edecbfe2f6e72dcddc837b5f8db1f4 (diff) |
test(nix/readTree): test marking behavior of readTree r/2950
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>
Diffstat (limited to 'nix')
5 files changed, 35 insertions, 0 deletions
diff --git a/nix/readTree/tests/default.nix b/nix/readTree/tests/default.nix index 06d4a12dd08f..3354a4fe5e75 100644 --- a/nix/readTree/tests/default.nix +++ b/nix/readTree/tests/default.nix @@ -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 ] diff --git a/nix/readTree/tests/test-marker/directory-marked/default.nix b/nix/readTree/tests/test-marker/directory-marked/default.nix new file mode 100644 index 000000000000..a3f961128e79 --- /dev/null +++ b/nix/readTree/tests/test-marker/directory-marked/default.nix @@ -0,0 +1,3 @@ +{ ... }: + +{} diff --git a/nix/readTree/tests/test-marker/directory-marked/nested/default.nix b/nix/readTree/tests/test-marker/directory-marked/nested/default.nix new file mode 100644 index 000000000000..a3f961128e79 --- /dev/null +++ b/nix/readTree/tests/test-marker/directory-marked/nested/default.nix @@ -0,0 +1,3 @@ +{ ... }: + +{} diff --git a/nix/readTree/tests/test-marker/file-children/one.nix b/nix/readTree/tests/test-marker/file-children/one.nix new file mode 100644 index 000000000000..a3f961128e79 --- /dev/null +++ b/nix/readTree/tests/test-marker/file-children/one.nix @@ -0,0 +1,3 @@ +{ ... }: + +{} diff --git a/nix/readTree/tests/test-marker/file-children/two.nix b/nix/readTree/tests/test-marker/file-children/two.nix new file mode 100644 index 000000000000..a3f961128e79 --- /dev/null +++ b/nix/readTree/tests/test-marker/file-children/two.nix @@ -0,0 +1,3 @@ +{ ... }: + +{} |