From e0921eba0a938172c53128de8b91e8310a74a51e Mon Sep 17 00:00:00 2001
From: Graham Christensen <graham@grahamc.com>
Date: Sun, 20 Feb 2022 12:18:11 -0500
Subject: [PATCH] Create a basic test which verifies we can't delete the
 derivation of aggregate jobs

---
 t/evaluator/evaluate-constituents-gc.t | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 t/evaluator/evaluate-constituents-gc.t

diff --git a/t/evaluator/evaluate-constituents-gc.t b/t/evaluator/evaluate-constituents-gc.t
new file mode 100644
index 00000000..a9b23e6c
--- /dev/null
+++ b/t/evaluator/evaluate-constituents-gc.t
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+use Setup;
+use Test2::V0;
+
+my $ctx = test_context();
+
+my $builds = $ctx->makeAndEvaluateJobset(
+    expression => 'constituents.nix',
+);
+
+my $constituentA = $builds->{"constituentA"};
+my $directAggregate = $builds->{"direct_aggregate"};
+my $indirectAggregate = $builds->{"indirect_aggregate"};
+
+is(system('nix-store', '--delete', $constituentA->drvpath), 256, "Deleting a constituent derivation fails");
+is(system('nix-store', '--delete', $directAggregate->drvpath), 256, "Deleting the direct aggregate derivation fails");
+is(system('nix-store', '--delete', $indirectAggregate->drvpath), 256, "Deleting the indirect aggregate derivation fails");
+
+done_testing;