diff options
| author | Robert Hensing <roberth@users.noreply.github.com> | 2023-07-19 17:28:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-19 17:28:05 +0200 |
| commit | 814f067760d029f532f990974a6df240d4320105 (patch) | |
| tree | 7a2e2329be756f263a0d207b71287fd4d2fffe7f /lib/path/tests | |
| parent | Merge pull request #244351 from emilylange/grafana-agent (diff) | |
| parent | lib.path.removePrefix: init (diff) | |
| download | nixpkgs-814f067760d029f532f990974a6df240d4320105.tar.gz | |
Merge pull request #238013 from tweag/lib.path.removePrefix
`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 9c5b752cf64a..3e4b216f099f 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; |
