test(nix/utils): unit test storePathName

Change-Id: I4208cf9e3c5e1d922ee5b5bffd034e4ac6d0e2c0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3543
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
sterni 2021-09-14 16:41:30 +02:00
parent 80fb67a75d
commit bef796d1d9

View file

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