about summary refs log tree commit diff
path: root/nix/readTree/tests/default.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-01-30T06·03+0100
committerProfpatsch <mail@profpatsch.de>2021-01-30T12·06+0000
commit768f5ec301d26bbf052b001df5b6b73bf8d6aa11 (patch)
treee3c93e57d5da2b729e29070d93c2d7b37effbf17 /nix/readTree/tests/default.nix
parent5f9e9a60e89775c990156f1a925128fc65865ee3 (diff)
feat(nix/readTree): add tests of the README example r/2164
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
Diffstat (limited to 'nix/readTree/tests/default.nix')
-rw-r--r--nix/readTree/tests/default.nix37
1 files changed, 37 insertions, 0 deletions
diff --git a/nix/readTree/tests/default.nix b/nix/readTree/tests/default.nix
new file mode 100644
index 000000000000..e591dc9fe94d
--- /dev/null
+++ b/nix/readTree/tests/default.nix
@@ -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
+]