aboutsummaryrefslogtreecommitdiffstats
path: root/t/parse_image_file_name.t
blob: 42435144352c43478fa7fbc719e1bdcd537e099e (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

use Test::Most;
use Isocheck;

bail_on_fail;

my %valid_names = (
    'Mageia-2-i586-DVD.iso' => {
        full    => 'Mageia-2-i586-DVD',
        name    => 'Mageia',
        version => '2',
        arch    => 'i586',
        medium  => 'DVD',
        ext     => 'iso'
    },
    'Mageia-2-alpha1-dual-CD.iso' => {
        full    => 'Mageia-2-alpha1-dual-CD',
        name    => 'Mageia',
        version => '2',
        arch    => 'dual',
        release => 'alpha1',
        medium  => 'CD',
        ext     => 'iso'
    },
    'Mageia-2-alpha3-LiveCD-GNOME-Europe1-i586-CD.iso' => {
        full    => 'Mageia-2-alpha3-LiveCD-GNOME-Europe1-i586-CD',
        name    => 'Mageia',
        version => '2',
        arch    => 'i586',
        release => 'alpha3',
        variant => 'LiveCD-GNOME-Europe1',
        medium  => 'CD',
        ext     => 'iso'
    },
    'Mageia-2-beta2-Vagrant-i586-build_123AA3.box' => {
        full    => 'Mageia-2-beta2-Vagrant-i586-build_123AA3',
        release => 'beta2',
        name    => 'Mageia',
        version => '2',
        arch    => 'i586',
        ext     => 'box',
        build   => 'build_123AA3',
        variant => 'Vagrant'
    },
    'Mageia-1-x86_64-CD.iso' => {
        full    => 'Mageia-1-x86_64-CD',
        name    => 'Mageia',
        version => '1',
        arch    => 'x86_64',
        medium  => 'CD',
        ext     => 'iso'
    },
    'Mageia-3-RC-LiveCD-KDE-Asia-x86_64.iso' => {
        full    => 'Mageia-3-RC-LiveCD-KDE-Asia-x86_64',
        release => 'RC',
        variant => 'LiveCD-KDE-Asia',
        name    => 'Mageia',
        version => '3',
        arch    => 'x86_64',
        ext     => 'iso'
    },
    'Mageia-2-Vagrant-i586.box' => {
        full    => 'Mageia-2-Vagrant-i586',
        name    => 'Mageia',
        version => '2',
        arch    => 'i586',
        ext     => 'box',
        variant => 'Vagrant'
    },
    'Mageia-3-nightly20111202-i586-DVD.iso' => {
        full    => 'Mageia-3-nightly20111202-i586-DVD',
        name    => 'Mageia',
        version => '3',
        arch    => 'i586',
        medium  => 'DVD',
        ext     => 'iso',
        release => 'nightly20111202'
    },
    'Mageia-2-nightly20111202-LiveCD-KDE-Asia-x86_64-build_123.iso' => {
        full    => 'Mageia-2-nightly20111202-LiveCD-KDE-Asia-x86_64-build_123',
        name    => 'Mageia',
        version => '2',
        arch    => 'x86_64',
        ext     => 'iso',
        variant => 'LiveCD-KDE-Asia',
        release => 'nightly20111202',
        build   => 'build_123'
    },
    'MagToo-4-nightly2-aDevice-i586-build_123_qa_pass.iso' => {
        full    => 'MagToo-4-nightly2-aDevice-i586-build_123_qa_pass',
        name    => 'MagToo',
        version => '4',
        arch    => 'i586',
        ext     => 'iso',
        variant => 'aDevice',
        release => 'nightly2',
        build   => 'build_123_qa_pass'
    }
);

my @invalid_names = (
    'mageia-2-i586-Dvd.iso',
    'mageia-i586-DVD.iso',
    'Mageia-2-i586-dvd.iso',
    'Mageia-1-x86_64-arm.iso',
    'Mageia-1-RC-LiveCD-GNOME-Africa.iso',
    'Mandriva-i586-DVD.iso',
    'Mageia-1.iso'
);

plan tests => scalar (keys %valid_names) + scalar @invalid_names;

my %got;

foreach (@invalid_names) {
    %got = parse_image_file_name($_);
    is_deeply(\%got, {}, "$_ is invalid.");
}

foreach my $name (keys %valid_names) {
    my $fields = $valid_names{$name};
    %got       = parse_image_file_name($name);
    is_deeply(\%got, $fields, "$name is valid.");
}

done_testing();