1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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();
|