From bef796d1d94034be36fdcb14b977fdc822fd2823 Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 14 Sep 2021 16:41:30 +0200 Subject: test(nix/utils): unit test storePathName Change-Id: I4208cf9e3c5e1d922ee5b5bffd034e4ac6d0e2c0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3543 Tested-by: BuildkiteCI Reviewed-by: tazjin --- nix/utils/tests/default.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'nix') diff --git a/nix/utils/tests/default.nix b/nix/utils/tests/default.nix index d8f38fde5cd6..366ddd7c9c94 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 ] -- cgit 1.4.1