rebuildperl: Fix a typo
[Fedora-Rebuild.git] / t / 12providers.t
blob6eeea12ffb0b808694f2b6c5a5144a1a698b58e2
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 use Test::More tests => 1 + 2 * 2 + 5;
7 use Fedora::Rebuild::Package;
8 use Fedora::Rebuild::RPM;
9 use Fedora::Rebuild::Providers;
10 use threads::shared;
12 sub build_package {
13 my ($name, $provides) = @_;
15 my $package = Fedora::Rebuild::Package->new(
16 'name' => $name,
17 workdir => 't/tmp',
18 dist => 'foo',
19 target => 'foo',
20 message => 'foo',
23 $package->provides(shared_clone($provides));
25 return $package;
29 my $providers = Fedora::Rebuild::Providers->new();
30 ok(defined $providers, 'create Fedora::Rebuild::Providers object');
32 my $a = build_package(
33 'a',
35 'a-main' => {
36 'a' => [
37 [Fedora::Rebuild::RPM::ANY, '']
39 'dual' => [
40 [Fedora::Rebuild::RPM::EQUAL, '1']
43 'a-libs' => {
44 'a.so' => [
45 [Fedora::Rebuild::RPM::ANY, '']
50 ok(defined $a, 'create package a');
51 $providers->insert($a);
52 is_deeply(
53 $providers->providers(),
55 'a' => [
56 [Fedora::Rebuild::RPM::ANY, '', $a, 'a-main']
58 'a.so' => [
59 [Fedora::Rebuild::RPM::ANY, '', $a, 'a-libs']
61 'dual' => [
62 [Fedora::Rebuild::RPM::EQUAL, '1', $a, 'a-main']
65 'insert a'
68 my $b = build_package(
69 'b',
71 'b-main' => {
72 'b' => [
73 [Fedora::Rebuild::RPM::ANY, '']
75 'dual' => [
76 [Fedora::Rebuild::RPM::EQUAL, '2']
79 'b-libs' => {
80 'b.so' => [
81 [Fedora::Rebuild::RPM::ANY, '']
86 ok(defined $b, 'create package b');
87 $providers->insert($b);
88 is_deeply(
89 $providers->providers(),
91 'a' => [
92 [Fedora::Rebuild::RPM::ANY, '', $a, 'a-main']
94 'a.so' => [
95 [Fedora::Rebuild::RPM::ANY, '', $a, 'a-libs']
97 'b' => [
98 [Fedora::Rebuild::RPM::ANY, '', $b, 'b-main']
100 'b.so' => [
101 [Fedora::Rebuild::RPM::ANY, '', $b, 'b-libs']
103 'dual' => [
104 [Fedora::Rebuild::RPM::EQUAL, '1', $a, 'a-main'],
105 [Fedora::Rebuild::RPM::EQUAL, '2', $b, 'b-main']
108 'insert b'
111 my @found = $providers->what_provides('x', Fedora::Rebuild::RPM::ANY, '');
112 is_deeply(
113 \@found,
115 'what provides (x *)'
118 @found = $providers->what_provides('a', Fedora::Rebuild::RPM::ANY, '');
119 is_deeply(
120 \@found,
122 [ $a, 'a-main' ]
124 'what provides (a *)'
127 @found = $providers->what_provides('dual',
128 Fedora::Rebuild::RPM::EQUAL|Fedora::Rebuild::RPM::GREATER, '3');
129 is_deeply(
130 \@found,
132 'what provides (dual >= 3)'
135 @found = $providers->what_provides('dual',
136 Fedora::Rebuild::RPM::EQUAL|Fedora::Rebuild::RPM::GREATER, '2');
137 is_deeply(
138 \@found,
140 [ $b, 'b-main' ]
142 'what provides (dual >= 2)'
145 @found = $providers->what_provides('dual',
146 Fedora::Rebuild::RPM::EQUAL|Fedora::Rebuild::RPM::GREATER, '1');
147 is_deeply(
148 \@found,
150 [ $a, 'a-main' ],
151 [ $b, 'b-main' ]
153 'what provides (dual >= 1)'