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();