about summary refs log tree commit diff
path: root/third_party/nix/src/tests/value-to-json.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/tests/value-to-json.cc')
-rw-r--r--third_party/nix/src/tests/value-to-json.cc91
1 files changed, 46 insertions, 45 deletions
diff --git a/third_party/nix/src/tests/value-to-json.cc b/third_party/nix/src/tests/value-to-json.cc
index 462d2fda0170..744698733415 100644
--- a/third_party/nix/src/tests/value-to-json.cc
+++ b/third_party/nix/src/tests/value-to-json.cc
@@ -1,12 +1,13 @@
-#include "value-to-json.hh"
+#include "libexpr/value-to-json.hh"
 
+#include <set>
 #include <sstream>
 
 #include <gtest/gtest.h>
 
-#include "store-api.hh"
-#include "value-to-xml.hh"
-#include "value.hh"
+#include "libexpr/value-to-xml.hh"
+#include "libexpr/value.hh"
+#include "libstore/store-api.hh"
 
 class ValueTest : public ::testing::Test {
  protected:
@@ -20,46 +21,46 @@ class XMLValueTest : public ValueTest {};
 
 namespace nix {
 
-class DummyStore : public Store {
+class DummyStore final : public Store {
  public:
   explicit DummyStore() : Store(Store::Params{}) {}
 
   std::string getUri() { return ""; }
-  virtual void queryPathInfoUncached(const StorePath&) {}
-  virtual void queryPathInfoUncached(
-      const StorePath&,
-      nix::Callback<std::shared_ptr<const nix::ValidPathInfo>>) noexcept {}
-  std::optional<StorePath> queryPathFromHashPart(const std::string& hashPart) {
-    return {};
-  }
-  StorePath addToStore(const std::string&, const std::string&,
-                       const StorePathSet&, nix::RepairFlag) {
-    return StorePath::dummy.clone();
-  }
-  StorePath addToStore(const std::string&, const Path&, bool, nix::HashType,
-                       nix::PathFilter&, nix::RepairFlag) {
-    return StorePath::dummy.clone();
+
+  void queryPathInfoUncached(
+      const Path& path,
+      Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept {}
+
+  Path queryPathFromHashPart(const std::string& hashPart) { return ""; }
+
+  Path addToStore(const std::string& name, const Path& srcPath,
+                  bool recursive = true, HashType hashAlgo = htSHA256,
+                  PathFilter& filter = defaultPathFilter,
+                  RepairFlag repair = NoRepair) {
+    return "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x";
   }
-  StorePath addTextToStore(const std::string&, const std::string&,
-                           const StorePathSet&, nix::RepairFlag) {
-    return StorePath::dummy.clone();
+
+  Path addTextToStore(const std::string& name, const std::string& s,
+                      const PathSet& references, RepairFlag repair = NoRepair) {
+    return "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x";
   }
 
-  void narFromPath(const StorePath&, Sink&) {}
-  void ensurePath(const StorePath&) {}
+  void narFromPath(const Path& path, Sink& sink) {}
 
-  BuildResult buildDerivation(const StorePath&, const BasicDerivation&,
-                              BuildMode) {
+  BuildResult buildDerivation(const Path& drvPath, const BasicDerivation& drv,
+                              BuildMode buildMode = bmNormal) {
     return BuildResult{};
   }
+
+  void ensurePath(const Path& path) {}
 };
 
 TEST_F(JSONValueTest, null) {
   std::stringstream ss;
   Value v;
   PathSet ps;
-  auto store = std::make_shared<DummyStore>();
-  EvalState s({}, ref<Store>(store), false);
+  std::shared_ptr<Store> store = std::make_shared<DummyStore>();
+  EvalState s({}, ref<Store>(store));
 
   mkNull(v);
   printValueAsJSON(s, true, v, ss, ps);
@@ -69,7 +70,7 @@ TEST_F(JSONValueTest, null) {
 TEST_F(JSONValueTest, BoolFalse) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -81,7 +82,7 @@ TEST_F(JSONValueTest, BoolFalse) {
 TEST_F(JSONValueTest, BoolTrue) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -93,7 +94,7 @@ TEST_F(JSONValueTest, BoolTrue) {
 TEST_F(JSONValueTest, IntPositive) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -105,7 +106,7 @@ TEST_F(JSONValueTest, IntPositive) {
 TEST_F(JSONValueTest, IntNegative) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -117,7 +118,7 @@ TEST_F(JSONValueTest, IntNegative) {
 TEST_F(JSONValueTest, String) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -129,7 +130,7 @@ TEST_F(JSONValueTest, String) {
 TEST_F(JSONValueTest, StringQuotes) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -141,7 +142,7 @@ TEST_F(JSONValueTest, StringQuotes) {
 TEST_F(JSONValueTest, Path) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -153,7 +154,7 @@ TEST_F(JSONValueTest, Path) {
 TEST_F(JSONValueTest, PathNoCopy) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -174,7 +175,7 @@ TEST_F(XMLValueTest, null) {
   Value v;
   PathSet ps;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({}, ref<Store>(store), false);
+  EvalState s({}, ref<Store>(store));
 
   mkNull(v);
   printValueAsXML(s, true, true, v, ss, ps);
@@ -184,7 +185,7 @@ TEST_F(XMLValueTest, null) {
 TEST_F(XMLValueTest, BoolFalse) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -196,7 +197,7 @@ TEST_F(XMLValueTest, BoolFalse) {
 TEST_F(XMLValueTest, BoolTrue) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -208,7 +209,7 @@ TEST_F(XMLValueTest, BoolTrue) {
 TEST_F(XMLValueTest, IntPositive) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -220,7 +221,7 @@ TEST_F(XMLValueTest, IntPositive) {
 TEST_F(XMLValueTest, IntNegative) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -232,7 +233,7 @@ TEST_F(XMLValueTest, IntNegative) {
 TEST_F(XMLValueTest, String) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -244,7 +245,7 @@ TEST_F(XMLValueTest, String) {
 TEST_F(XMLValueTest, StringQuotes) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -260,7 +261,7 @@ TEST_F(XMLValueTest, StringQuotes) {
 TEST_F(XMLValueTest, Path) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;
 
@@ -276,7 +277,7 @@ TEST_F(XMLValueTest, Path) {
 TEST_F(XMLValueTest, PathNoCopy) {
   std::stringstream ss;
   auto store = std::make_shared<DummyStore>();
-  EvalState s({"."}, ref<Store>(store), false);
+  EvalState s({"."}, ref<Store>(store));
   Value v;
   PathSet ps;