aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/tests
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 10:56:22 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 10:56:22 -0500
commit989b8065b45e52a8df2a803b1a72e0d0a7c35536 (patch)
treeffd7d779cf35dc13396aef3b1871a7bc954af350 /src/libstore/tests
parent08b8657978de0d56064aad9c3e925b64d91b28a2 (diff)
parente9fc1e4fdb0ab5adb6b163c3db361b86a4f5c69b (diff)
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'src/libstore/tests')
-rw-r--r--src/libstore/tests/path-with-outputs.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/libstore/tests/path-with-outputs.cc b/src/libstore/tests/path-with-outputs.cc
new file mode 100644
index 000000000..350ea7ffd
--- /dev/null
+++ b/src/libstore/tests/path-with-outputs.cc
@@ -0,0 +1,46 @@
+#include "path-with-outputs.hh"
+
+#include <gtest/gtest.h>
+
+namespace nix {
+
+TEST(parseOutputsSpec, basic)
+{
+ {
+ auto [prefix, outputsSpec] = parseOutputsSpec("foo");
+ ASSERT_EQ(prefix, "foo");
+ ASSERT_TRUE(std::get_if<DefaultOutputs>(&outputsSpec));
+ }
+
+ {
+ auto [prefix, outputsSpec] = parseOutputsSpec("foo^*");
+ ASSERT_EQ(prefix, "foo");
+ ASSERT_TRUE(std::get_if<AllOutputs>(&outputsSpec));
+ }
+
+ {
+ auto [prefix, outputsSpec] = parseOutputsSpec("foo^out");
+ ASSERT_EQ(prefix, "foo");
+ ASSERT_TRUE(std::get<OutputNames>(outputsSpec) == OutputNames({"out"}));
+ }
+
+ {
+ auto [prefix, outputsSpec] = parseOutputsSpec("foo^out,bin");
+ ASSERT_EQ(prefix, "foo");
+ ASSERT_TRUE(std::get<OutputNames>(outputsSpec) == OutputNames({"out", "bin"}));
+ }
+
+ {
+ auto [prefix, outputsSpec] = parseOutputsSpec("foo^bar^out,bin");
+ ASSERT_EQ(prefix, "foo^bar");
+ ASSERT_TRUE(std::get<OutputNames>(outputsSpec) == OutputNames({"out", "bin"}));
+ }
+
+ {
+ auto [prefix, outputsSpec] = parseOutputsSpec("foo^&*()");
+ ASSERT_EQ(prefix, "foo^&*()");
+ ASSERT_TRUE(std::get_if<DefaultOutputs>(&outputsSpec));
+ }
+}
+
+}