summaryrefslogtreecommitdiffstats
path: root/t/superuser--urpmi_update.t
blob: 475fb31cf03be1a434ea04530a0118fd2b15fbea (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
#!/usr/bin/perl

use strict;
use lib '.', 't';
use helper;
use Test::More 'no_plan';
BEGIN { use_ok 'urpm::cfg' }

need_root_and_prepare();

try1();
try2();

sub try1 {
    urpmi_addmedia("--distrib $::pwd");
    check_urpmi('various', 'various2');

    urpmi_update('--ignore Various');
    check_conf('Various' => { ignore => 1 });
    test_urpmi_fail('--auto various');

    check_conf('Various Debug' => { ignore => 1 });
    test_urpmi_fail('various-debug');

    urpmi_update('--no-ignore "Various Debug"');
    urpmi_update('"Various Debug"');
    check_conf('Various Debug' => { ignore => undef });
    check_urpmi('various-debug');

    urpmi_removemedia('-a');
}
# same as above, except urpmi.update is done before urpmi.update --no-ignore
sub try2 {
    my ($want, $want3, $options) = @_;

    urpmi_addmedia("--distrib $::pwd");

    urpmi_update('"Various Debug"');
    check_conf('Various Debug' => { ignore => 1 });
    test_urpmi_fail('various-debug');

    urpmi_update('--no-ignore "Various Debug"');
    check_conf('Various Debug' => { ignore => undef });
    check_urpmi('various-debug');

    urpmi_removemedia('-a');
}

sub check_conf {
    my (%want) = @_;
    my $config = urpm::cfg::load_config("root/etc/urpmi/urpmi.cfg");
    my %media = map { $_->{name} => $_ } @{$config->{media}};
    foreach my $name (keys %want) {
	foreach my $field (keys %{$want{$name}}) {
	    my $val = $want{$name}{$field};
	    is($media{$name}{$field}, $want{$name}{$field}, "$name:$field");
	}
    }
}

sub check_urpmi {
    my (@names) = @_;
    urpmi(join(' ', @names));
    check_installed_and_remove(@names);
}