diff options
| author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-01-18 18:15:55 +0100 |
|---|---|---|
| committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-02-13 14:01:17 +0100 |
| commit | 1a2c2846b0933b596c51e964acb8a45ab9a13691 (patch) | |
| tree | cccb126ed6f1c06e3cd9caecf5c45a788c474329 /lib/path/tests | |
| parent | Merge pull request #208887 from tweag/lib.path.append (diff) | |
| download | nixpkgs-1a2c2846b0933b596c51e964acb8a45ab9a13691.tar.gz | |
lib.path.subpath.join: init
This function can be used to safely join subpaths together
Diffstat (limited to 'lib/path/tests')
| -rw-r--r-- | lib/path/tests/unit.nix | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/path/tests/unit.nix b/lib/path/tests/unit.nix index a1a45173a909..61c4ab4d6f2e 100644 --- a/lib/path/tests/unit.nix +++ b/lib/path/tests/unit.nix @@ -107,6 +107,36 @@ let expected = true; }; + # Test examples from the lib.path.subpath.join documentation + testSubpathJoinExample1 = { + expr = subpath.join [ "foo" "bar/baz" ]; + expected = "./foo/bar/baz"; + }; + testSubpathJoinExample2 = { + expr = subpath.join [ "./foo" "." "bar//./baz/" ]; + expected = "./foo/bar/baz"; + }; + testSubpathJoinExample3 = { + expr = subpath.join [ ]; + expected = "./."; + }; + testSubpathJoinExample4 = { + expr = (builtins.tryEval (subpath.join [ /foo ])).success; + expected = false; + }; + testSubpathJoinExample5 = { + expr = (builtins.tryEval (subpath.join [ "" ])).success; + expected = false; + }; + testSubpathJoinExample6 = { + expr = (builtins.tryEval (subpath.join [ "/foo" ])).success; + expected = false; + }; + testSubpathJoinExample7 = { + expr = (builtins.tryEval (subpath.join [ "../foo" ])).success; + expected = false; + }; + # Test examples from the lib.path.subpath.normalise documentation testSubpathNormaliseExample1 = { expr = subpath.normalise "foo//bar"; |
