summary refs log tree commit diff
path: root/lib/tests
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2017-05-30 21:48:32 +0200
committerzimbatm <zimbatm@zimbatm.com>2017-05-30 20:48:32 +0100
commit3fa1be6f491d9f3ce359234aa1e479e6d91a598f (patch)
tree636e4ef385942c79191341d0d1f215acdf051b43 /lib/tests
parentc6ea7d3a66e0f6b573d7da849924b269a0a391e9 (diff)
downloadnixlib-3fa1be6f491d9f3ce359234aa1e479e6d91a598f.tar
nixlib-3fa1be6f491d9f3ce359234aa1e479e6d91a598f.tar.gz
nixlib-3fa1be6f491d9f3ce359234aa1e479e6d91a598f.tar.bz2
nixlib-3fa1be6f491d9f3ce359234aa1e479e6d91a598f.tar.lz
nixlib-3fa1be6f491d9f3ce359234aa1e479e6d91a598f.tar.xz
nixlib-3fa1be6f491d9f3ce359234aa1e479e6d91a598f.tar.zst
nixlib-3fa1be6f491d9f3ce359234aa1e479e6d91a598f.zip
Add `isStorePath` tests (#26223)
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/misc.nix38
1 files changed, 34 insertions, 4 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 334e1a707334..f55f3d712727 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -1,7 +1,6 @@
 # to run these tests:
 # nix-instantiate --eval --strict nixpkgs/lib/tests/misc.nix
 # if the resulting list is empty, all tests passed
-let inherit (builtins) add; in
 with import ../default.nix;
 
 runTests {
@@ -88,6 +87,37 @@ runTests {
     expected = [ "2001" "db8" "0" "0042" "" "8a2e" "370" "" ];
   };
 
+  testIsStorePath =  {
+    expr =
+      let goodPath =
+            "/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11";
+      in {
+        storePath = isStorePath goodPath;
+        storePathAppendix = isStorePath
+          "${goodPath}/bin/python";
+        nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
+        asPath = isStorePath (builtins.toPath goodPath);
+        otherPath = isStorePath "/something/else";
+        otherVals = {
+          attrset = isStorePath {};
+          list = isStorePath [];
+          int = isStorePath 42;
+        };
+      };
+    expected = {
+      storePath = true;
+      storePathAppendix = false;
+      nonAbsolute = false;
+      asPath = true;
+      otherPath = false;
+      otherVals = {
+        attrset = false;
+        list = false;
+        int = false;
+      };
+    };
+  };
+
 # LISTS
 
   testFilter = {
@@ -266,14 +296,14 @@ runTests {
           res4 = let x = defaultOverridableDelayableArgs id { a = 7; };
                 in (x.merge) ( x: { b = 10; });
           res5 = let x = defaultOverridableDelayableArgs id { a = 7; };
-                in (x.merge) ( x: { a = add x.a 3; });
-          res6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = add; }; };
+                in (x.merge) ( x: { a = builtins.add x.a 3; });
+          res6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = builtins.add; }; };
                      y = x.merge {};
                 in (y.merge) { a = 10; };
 
           resRem7 = res6.replace (a: removeAttrs a ["a"]);
 
-          resReplace6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = add; }; };
+          resReplace6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = builtins.add; }; };
                             x2 = x.merge { a = 20; }; # now we have 27
                         in (x2.replace) { a = 10; }; # and override the value by 10