about summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-09-14T14·41+0200
committersterni <sternenseemann@systemli.org>2021-09-17T11·00+0000
commitbef796d1d94034be36fdcb14b977fdc822fd2823 (patch)
treebd265811cca25795d0aa5e9a99fc2b7c974e9a5f /nix
parent80fb67a75dc25ae64f87836ddd2b7f5c506a2a6c (diff)
test(nix/utils): unit test storePathName r/2880
Change-Id: I4208cf9e3c5e1d922ee5b5bffd034e4ac6d0e2c0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3543
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'nix')
-rw-r--r--nix/utils/tests/default.nix16
1 files changed, 16 insertions, 0 deletions
diff --git a/nix/utils/tests/default.nix b/nix/utils/tests/default.nix
index d8f38fde5c..366ddd7c9c 100644
--- a/nix/utils/tests/default.nix
+++ b/nix/utils/tests/default.nix
@@ -13,6 +13,7 @@ let
     isDirectory
     isRegularFile
     isSymlink
+    storePathName
     ;
 
   assertUtilsPred = msg: act: exp: [
@@ -56,8 +57,23 @@ let
     (assertThrows "isSymlink throws on missing file"
       (isSymlink ./does-not-exist))
   ]);
+
+  cheddarStorePath =
+    builtins.unsafeDiscardStringContext depot.tools.cheddar.outPath;
+
+  storePathNameTests = it "correctly gets the basename of a store path" [
+    (assertEq "base name of a derivation"
+      (storePathName depot.tools.cheddar) depot.tools.cheddar.name)
+    (assertEq "base name of a store path string"
+      (storePathName cheddarStorePath) depot.tools.cheddar.name)
+    (assertEq "base name of a path within a store path"
+      (storePathName "${cheddarStorePath}/bin/cheddar") "cheddar")
+    (assertEq "base name of a path"
+      (storePathName ../default.nix) "default.nix")
+  ];
 in
 
 runTestsuite "nix.utils" [
   pathPredicates
+  storePathNameTests
 ]