aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-02-17 17:53:21 +0000
committerRomain d'Alverny <rda@mageia.org>2012-02-17 17:53:21 +0000
commit10afa7f61593c6ee82f7256c5dfa29104ba19e52 (patch)
tree0d646902bde98ebdfa5fc7f4ead3c86349ca0667 /t
parent48d5e738940610746ccf2c560751d16c3b688c4b (diff)
downloadisocheck-10afa7f61593c6ee82f7256c5dfa29104ba19e52.tar
isocheck-10afa7f61593c6ee82f7256c5dfa29104ba19e52.tar.gz
isocheck-10afa7f61593c6ee82f7256c5dfa29104ba19e52.tar.bz2
isocheck-10afa7f61593c6ee82f7256c5dfa29104ba19e52.tar.xz
isocheck-10afa7f61593c6ee82f7256c5dfa29104ba19e52.zip
New Isocheck module to replace Tools + working tests
Code improved thx to misc, boklm, tv and guillomovitch.
Diffstat (limited to 't')
-rw-r--r--t/00_load.t10
-rw-r--r--t/parse_image_file_name.t126
2 files changed, 136 insertions, 0 deletions
diff --git a/t/00_load.t b/t/00_load.t
new file mode 100644
index 0000000..4a923e4
--- /dev/null
+++ b/t/00_load.t
@@ -0,0 +1,10 @@
+#!/usr/bin/perl -w
+
+use Test::More tests => 2;
+
+BEGIN {
+use_ok( 'Isocheck' );
+require_ok('Isocheck');
+}
+
+diag( "Testing Isocheck $Isocheck::VERSION" ); \ No newline at end of file
diff --git a/t/parse_image_file_name.t b/t/parse_image_file_name.t
new file mode 100644
index 0000000..4243514
--- /dev/null
+++ b/t/parse_image_file_name.t
@@ -0,0 +1,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(); \ No newline at end of file