diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-06-16 00:19:33 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-07-10 21:25:43 +0200 |
commit | 6626d8cc4de80f063da7ab871ecdc66f40f28e0b (patch) | |
tree | 1c4f1874c16d2a62f3736542a896023718ed4862 /lib/path/tests | |
parent | 7a49b67eb2dd419d4a6d4ae4e968d64fd051f140 (diff) |
lib.path.removePrefix: init
Diffstat (limited to 'lib/path/tests')
-rw-r--r-- | lib/path/tests/unit.nix | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/path/tests/unit.nix b/lib/path/tests/unit.nix index 9c5b752cf64a3..3e4b216f099ff 100644 --- a/lib/path/tests/unit.nix +++ b/lib/path/tests/unit.nix @@ -3,7 +3,7 @@ { libpath }: let lib = import libpath; - inherit (lib.path) hasPrefix append subpath; + inherit (lib.path) hasPrefix removePrefix append subpath; cases = lib.runTests { # Test examples from the lib.path.append documentation @@ -57,6 +57,23 @@ let expected = true; }; + testRemovePrefixExample1 = { + expr = removePrefix /foo /foo/bar/baz; + expected = "./bar/baz"; + }; + testRemovePrefixExample2 = { + expr = removePrefix /foo /foo; + expected = "./."; + }; + testRemovePrefixExample3 = { + expr = (builtins.tryEval (removePrefix /foo/bar /foo)).success; + expected = false; + }; + testRemovePrefixExample4 = { + expr = removePrefix /. /foo; + expected = "./foo"; + }; + # Test examples from the lib.path.subpath.isValid documentation testSubpathIsValidExample1 = { expr = subpath.isValid null; |