about summary refs log tree commit diff
path: root/third_party/nix/src/tests/derivations_test.cc
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-03T23·09-0400
committerglittershark <grfn@gws.fyi>2020-08-03T23·17+0000
commit31b9578ad028cf5eff7fa426f134891cbba83ca9 (patch)
tree47a07afe7482a448df21f94b9973ed1809347f66 /third_party/nix/src/tests/derivations_test.cc
parent661353f2006a46216fe1a7fa2ae5abd08d540f49 (diff)
fix(3p/nix): Fix parseDrvPathWithOutputs r/1571
At some point the behavior of this function got changed as part of our
cleanup - this fixes it to behave the way the rest of the codebase
expects (and how it is documented in the header) and covers it with a
few tests.

Change-Id: Id4c91232968e73489cd866fb4a2a84bcf20d875e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1629
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'third_party/nix/src/tests/derivations_test.cc')
-rw-r--r--third_party/nix/src/tests/derivations_test.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/third_party/nix/src/tests/derivations_test.cc b/third_party/nix/src/tests/derivations_test.cc
index e026fbe3b11c..1e2719addaf1 100644
--- a/third_party/nix/src/tests/derivations_test.cc
+++ b/third_party/nix/src/tests/derivations_test.cc
@@ -103,4 +103,34 @@ RC_GTEST_FIXTURE_PROP(DerivationsTest, UnparseParseRoundTrip,
   AssertDerivationsEqual(drv, parsed);
 }
 
+class ParseDrvPathWithOutputsTest : public DerivationsTest {};
+
+TEST(ParseDrvPathWithOutputsTest, ParseDrvPathWithOutputs) {
+  auto input = "/nix/store/my51f75kp056md84gq2v08pd140pcz57-test.drv!out";
+  auto result = nix::parseDrvPathWithOutputs(input);
+
+  ASSERT_EQ(result.first,
+            "/nix/store/my51f75kp056md84gq2v08pd140pcz57-test.drv");
+  ASSERT_EQ(result.second, nix::PathSet{"out"});
+}
+
+TEST(ParseDrvPathWithOutputsTest, ParseDrvPathWithMultipleOutputs) {
+  auto input = "/nix/store/my51f75kp056md84gq2v08pd140pcz57-test.drv!out,dev";
+  auto result = nix::parseDrvPathWithOutputs(input);
+
+  nix::PathSet expected = {"out", "dev"};
+
+  ASSERT_EQ(result.first,
+            "/nix/store/my51f75kp056md84gq2v08pd140pcz57-test.drv");
+  ASSERT_EQ(result.second, expected);
+}
+
+TEST(ParseDrvPathWithOutputsTest, ParseDrvPathWithNoOutputs) {
+  auto input = "/nix/store/my51f75kp056md84gq2v08pd140pcz57-test";
+  auto result = nix::parseDrvPathWithOutputs(input);
+
+  ASSERT_EQ(result.first, "/nix/store/my51f75kp056md84gq2v08pd140pcz57-test");
+  ASSERT_EQ(result.second, nix::PathSet());
+}
+
 }  // namespace nix