about summary refs log tree commit diff
path: root/third_party/nix
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix')
-rw-r--r--third_party/nix/src/tests/dummy-store.hh7
-rw-r--r--third_party/nix/src/tests/value-to-json.cc4
2 files changed, 8 insertions, 3 deletions
diff --git a/third_party/nix/src/tests/dummy-store.hh b/third_party/nix/src/tests/dummy-store.hh
index efa4390d28eb..d0f8bf14b60f 100644
--- a/third_party/nix/src/tests/dummy-store.hh
+++ b/third_party/nix/src/tests/dummy-store.hh
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <filesystem>
 #include "libstore/store-api.hh"
 
 namespace nix::tests {
@@ -20,7 +21,11 @@ class DummyStore final : public Store {
                   bool recursive = true, HashType hashAlgo = htSHA256,
                   PathFilter& filter = defaultPathFilter,
                   RepairFlag repair = NoRepair) {
-    return "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x";
+    if (srcPath == "/exists-for-tests") {
+      return "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x";
+    }
+
+    throw SysError("file does not exist");
   }
 
   Path addTextToStore(const std::string& name, const std::string& s,
diff --git a/third_party/nix/src/tests/value-to-json.cc b/third_party/nix/src/tests/value-to-json.cc
index 19591b6fa1c7..fddeae512b69 100644
--- a/third_party/nix/src/tests/value-to-json.cc
+++ b/third_party/nix/src/tests/value-to-json.cc
@@ -116,7 +116,7 @@ TEST_F(JSONValueTest, Path) {
   Value v;
   PathSet ps;
 
-  mkPath(v, "test");
+  mkPathNoCopy(v, "/exists-for-tests");
   printValueAsJSON(s, true, v, ss, ps);
   ASSERT_EQ(ss.str(), "\"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x\"");
 }
@@ -128,7 +128,7 @@ TEST_F(JSONValueTest, PathNoCopy) {
   Value v;
   PathSet ps;
 
-  mkPathNoCopy(v, "test");
+  mkPathNoCopy(v, "/exists-for-tests");
   printValueAsJSON(s, true, v, ss, ps);
   ASSERT_EQ(ss.str(), "\"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x\"");
 }