summaryrefslogtreecommitdiffstats
path: root/t/superuser--addmedia.t
diff options
context:
space:
mode:
Diffstat (limited to 't/superuser--addmedia.t')
-rw-r--r--t/superuser--addmedia.t83
1 files changed, 56 insertions, 27 deletions
diff --git a/t/superuser--addmedia.t b/t/superuser--addmedia.t
index 6080063b..776da2d1 100644
--- a/t/superuser--addmedia.t
+++ b/t/superuser--addmedia.t
@@ -9,44 +9,73 @@ BEGIN { use_ok 'urpm::cfg' }
need_root_and_prepare();
my $name = 'various';
+my $name2 = 'various2';
my @fields = qw(hdlist synthesis with_hdlist media_info_dir virtual);
-try_medium('', { media_info_dir => 'media_info' });
+try_medium({ media_info_dir => 'media_info' }, '');
-try_medium('--probe-hdlist',
- { hdlist => 1, media_info_dir => 'media_info' });
-try_medium('with media_info/hdlist.cz',
- { hdlist => 1, media_info_dir => 'media_info' });
-try_medium("with ../media_info/hdlist_$name.cz",
- { hdlist => 1, with_hdlist => "../media_info/hdlist_$name.cz" });
-try_medium('--probe-synthesis',
- { synthesis => 1, media_info_dir => 'media_info' });
-try_medium('with media_info/synthesis.hdlist.cz',
- { synthesis => 1, media_info_dir => 'media_info' });
-try_medium("with ../media_info/synthesis.hdlist_$name.cz",
- { synthesis => 1, with_hdlist => "../media_info/synthesis.hdlist_$name.cz" });
+try_medium({ hdlist => 1, media_info_dir => 'media_info' },
+ '--probe-hdlist');
+try_medium({ hdlist => 1, media_info_dir => 'media_info' },
+ 'with media_info/hdlist.cz');
+try_medium({ hdlist => 1,
+ with_hdlist => "../media_info/hdlist_$name.cz",
+ with_hdlist2 => "../media_info/hdlist_$name2.cz" },
+ "with ../media_info/hdlist_$name.cz",
+ "with ../media_info/hdlist_$name2.cz",
+ );
+
+try_medium({ synthesis => 1, media_info_dir => 'media_info' },
+ '--probe-synthesis');
+try_medium({ synthesis => 1, media_info_dir => 'media_info' },
+ 'with media_info/synthesis.hdlist.cz');
+try_medium({ synthesis => 1,
+ with_hdlist => "../media_info/synthesis.hdlist_$name.cz",
+ with_hdlist2 => "../media_info/synthesis.hdlist_$name2.cz" },
+ "with ../media_info/synthesis.hdlist_$name.cz",
+ "with ../media_info/synthesis.hdlist_$name2.cz");
sub try_medium {
- my ($options, $want) = @_;
+ my ($want, $options, $o_options2) = @_;
+ my $want2 = { %$want, with_hdlist => $want->{with_hdlist2} || $want->{with_hdlist} };
+
+ try_medium_($want, $want2, $options, ($o_options2 || $options));
+
+ $want2->{virtual} = $want->{virtual} = 1;
+ try_medium_($want, $want2, '--virtual ' . $options, '--virtual ' . ($o_options2 || $options));
+}
+
+sub try_medium_ {
+ my ($want, $want2, $options, $options2) = @_;
+
urpmi_addmedia("$name $::pwd/media/$name $options");
- try_($want);
- urpmi_removemedia($name);
- urpmi_addmedia("$name $::pwd/media/$name --virtual $options");
- try_({ virtual => 1, %$want });
+ check_conf($want);
+ check_urpmi($name);
+ {
+ urpmi_addmedia("$name2 $::pwd/media/$name2 $options2");
+ check_conf($want, $want2);
+ check_urpmi($name, $name2);
+ urpmi_removemedia($name2);
+ }
urpmi_removemedia($name);
}
-sub try_ {
- my ($want) = @_;
+sub check_conf {
+ my (@want) = @_;
my $config = urpm::cfg::load_config("root/etc/urpmi/urpmi.cfg");
- my ($medium) = @{$config->{media}};
- ok($medium);
- foreach my $field (@fields) {
- is($medium->{$field}, $want->{$field}, $field);
+ is(int(@{$config->{media}}), int(@want));
+ foreach my $i (0 .. $#want) {
+ my ($medium, $want) = ($config->{media}[$i], $want[$i]);
+ foreach my $field (@fields) {
+ is($medium->{$field}, $want->{$field}, $field);
+ }
}
- urpmi($name);
- is(`rpm -qa --root $::pwd/root`, "$name-1-1\n");
- urpme($name);
+}
+sub check_urpmi {
+ my (@names) = @_;
+ urpmi(join(' ', @names));
+ is(`rpm -qa --root $::pwd/root | sort`, join('', map { "$_-1-1\n" } @names));
+ urpme(join(' ', @names));
}