aboutsummaryrefslogtreecommitdiffstats
path: root/t/emi_finisher.t
blob: e710732ece0213e2d030abe339cb33d4557d964b (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
use Test::More;
use Iurt::Emi;

my $config = {
    arch => ['i586', 'x86_64', 'armv5tl'],
    mandatory_arch => ['i586', 'x86_64'],
    queue => '.',
};

my %pkg_tree = (
    '20160113183431.nobody.valstar.23515' => {
	'target' => 'cauldron',
	'media' => {
	    'core/release' => {
		'done_arch' => {
		    'i586' => 1,
		    'x86_64' => 1,
		    'src' => 1
		},
		'rpms' => [
		    'iurt-test-package-debuginfo-1.4.0-2.mga6.i586.rpm',
		    'iurt-test-package-1.4.0-2.mga6.i586.rpm',
		    'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
		    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
		    'iurt-test-package-1.4.0-2.mga6.x86_64.rpm'
		],
		'path' => '/cauldron/core/release',
	    }
	},
	'rpms' => [
	    'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
	    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
	    'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
	    'iurt-test-package-debuginfo-1.4.0-2.mga6.i586.rpm',
	    'iurt-test-package-1.4.0-2.mga6.i586.rpm'
	],
	'srpms' => [
	    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
	],
    },
    '20160113183432.nobody.valstar.23515' => {
	'target' => 'cauldron',
	'media' => {
	    'core/release' => {
		'uploaded' => 1,
		'done_arch' => {
		    'armv5tl' => 1,
		    'i586' => 1,
		    'x86_64' => 1,
		    'src' => 1
		},
		'rpms' => [
		    'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
		    'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm',
		    'iurt-test-package-doc-1.4.0-2.mga6.noarch.rpm',
		    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
		],
		'path' => '/cauldron/core/release',
	    }
	},
	'rpms' => [
	    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
	    'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
	    'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm',
	    'iurt-test-package-doc-1.4.0-2.mga6.noarch.rpm',
	],
	'srpms' => [
	    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
	],
    },
    '20160113183432.nobody.valstar.23516' => {
	'target' => 'cauldron',
	'media' => {
	    'core/release' => {
		'uploaded' => 1,
		'done_arch' => {
		    'armv5tl' => 1,
		    'i586' => 1,
		    'x86_64' => 1,
		    'src' => 1
		},
		'rpms' => [
		    'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
		    'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm',
		    'iurt-test-package-doc-1.4.0-2.mga6.noarch.rpm',
		    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
		],
		'path' => '/cauldron/core/release',
	    }
	},
	'rpms' => [
	    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
	    'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
	    'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm',
	    'iurt-test-package-doc-1.4.0-2.mga6.noarch.rpm',
	],
	'srpms' => [
	    '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
	],
    },
);

my %targets = find_prefixes_ready_to_upload($config, %pkg_tree);

is($targets{cauldron}{'core/release'}{arch_finisher}{i586}, '20160113183431.nobody.valstar.23515');
is($targets{cauldron}{'core/release'}{arch_finisher}{x86_64}, '20160113183431.nobody.valstar.23515');
is($targets{cauldron}{'core/release'}{arch_finisher}{armv5tl}, '20160113183432.nobody.valstar.23515');
ok(!$targets{cauldron}{'core/release'}{arch_finisher}{noarch});

foreach my $target (keys %targets) {
    foreach my $media (keys %{$targets{$target}}) {
	my %is_finisher;

	foreach (values %{$targets{$target}{$media}{arch_finisher}}) {
	    $is_finisher{$_} = 1;
	}

	foreach my $prefix (@{$targets{$target}{$media}{to_upload}}) {
	    next if $is_finisher{$prefix};
	    is($prefix, '20160113183432.nobody.valstar.23516');
	}

	foreach my $prefix (keys %is_finisher) {
	    isnt($prefix, '20160113183432.nobody.valstar.23516');
	}
    }
}

done_testing();