aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--t/queue.t60
1 files changed, 60 insertions, 0 deletions
diff --git a/t/queue.t b/t/queue.t
new file mode 100644
index 0000000..d9f8056
--- /dev/null
+++ b/t/queue.t
@@ -0,0 +1,60 @@
+use Test::More;
+use Iurt::Queue;
+
+$config = {};
+
+my $media = 'core/release';
+my $bot = 'iurt';
+
+my $b1 = {
+ bot => $bot,
+ host => 'h1',
+ date => 20220401,
+ pid => 1,
+ 'arch' => 'a1',
+ 'time' => 42
+};
+
+my $b2 = {
+ bot => $bot,
+ host => 'h1',
+ date => 20220401,
+ pid => 2,
+ 'arch' => 'a2',
+ 'time' => 42
+};
+
+my $b3 = {
+ bot => $bot,
+ host => 'h2',
+ date => 20220401,
+ pid => 1,
+ 'arch' => 'a1',
+ 'time' => 42
+};
+
+sub create_ent {
+ my %ent;
+ $ent->{media}{$media}{bot} = [$b1, $b2, $b3];
+ return $ent;
+}
+
+my $ent, $expected_ent;
+
+$ent = create_ent();
+remove_bot_from_package($ent, $media, 'h1', 42);
+is_deeply $ent->{media}{$media}{bot}, [$b1, $b2, $b3] or diag explain $ent->{media}{$media}{bot};
+
+$ent = create_ent();
+remove_bot_from_package($ent, $media, 'h1', 1);
+is_deeply $ent->{media}{$media}{bot}, [$b2, $b3] or diag explain $ent->{media}{$media}{bot};
+
+$ent = create_ent();
+remove_bot_from_package($ent, $media, 'h2', 1);
+is_deeply $ent->{media}{$media}{bot}, [$b1, $b2] or diag explain $ent->{media}{$media}{bot};
+
+$ent = create_ent();
+remove_bot_from_package($ent, $media, 'h1', 2);
+is_deeply $ent->{media}{$media}{bot}, [$b1, $b3] or diag explain $ent->{media}{$media}{bot};
+
+done_testing();