From 0573b8263cfa3a66ab9dd9ccc0f82714bae2263d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 22 May 2010 18:50:49 +0200 Subject: Add some comirror-specific tests --- test/50-comirror.t | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/60-comirror-setup.t | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/next-loop/1.jpg | 0 test/next-loop/1.xhtml | 14 ++++++++++++++ test/next-loop/2.jpg | 0 test/next-loop/2.xhtml | 14 ++++++++++++++ test/next-loop/3.jpg | 0 test/next-loop/3.xhtml | 14 ++++++++++++++ test/next-loop/4.jpg | 0 test/next-loop/4.xhtml | 14 ++++++++++++++ test/next-loop/5.jpg | 0 test/next-loop/5.xhtml | 14 ++++++++++++++ test/next-none/1.jpg | 0 test/next-none/1.xhtml | 14 ++++++++++++++ test/next-none/2.jpg | 0 test/next-none/2.xhtml | 14 ++++++++++++++ test/next-none/3.jpg | 0 test/next-none/3.xhtml | 14 ++++++++++++++ test/next-none/4.jpg | 0 test/next-none/4.xhtml | 14 ++++++++++++++ test/next-none/5.jpg | 0 test/next-none/5.xhtml | 13 +++++++++++++ 22 files changed, 230 insertions(+) create mode 100755 test/50-comirror.t create mode 100755 test/60-comirror-setup.t create mode 100644 test/next-loop/1.jpg create mode 100644 test/next-loop/1.xhtml create mode 100644 test/next-loop/2.jpg create mode 100644 test/next-loop/2.xhtml create mode 100644 test/next-loop/3.jpg create mode 100644 test/next-loop/3.xhtml create mode 100644 test/next-loop/4.jpg create mode 100644 test/next-loop/4.xhtml create mode 100644 test/next-loop/5.jpg create mode 100644 test/next-loop/5.xhtml create mode 100644 test/next-none/1.jpg create mode 100644 test/next-none/1.xhtml create mode 100644 test/next-none/2.jpg create mode 100644 test/next-none/2.xhtml create mode 100644 test/next-none/3.jpg create mode 100644 test/next-none/3.xhtml create mode 100644 test/next-none/4.jpg create mode 100644 test/next-none/4.xhtml create mode 100644 test/next-none/5.jpg create mode 100644 test/next-none/5.xhtml diff --git a/test/50-comirror.t b/test/50-comirror.t new file mode 100755 index 0000000..3dc25b7 --- /dev/null +++ b/test/50-comirror.t @@ -0,0 +1,46 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; +use Cwd; +use Test::More tests => 26; +use Test::Cmd; + +for my $next_type (qw/ loop none /) { + + my $test = Test::Cmd->new( prog => 'bin/comirror', workdir => q{} ); + my $cwd = $test->workdir(); + + my $next_base = 'file://' . getcwd() . "/test/next-${next_type}"; + my ($str, $exit); + + ok($test, "Create Test::Cmd object ($next_type)"); + + $test->write('image_re', "${next_base}/.+"); + $exit = $test->run( + chdir => $cwd, + args => "${next_base}/1.xhtml", + ); + + ok($exit == 0, 'First run: return 0'); + + isnt($test->stdout, q{}, 'First run: Non-empty stdout'); + is ($test->stderr, q{}, 'First run: Empty stderr'); + + $test->read(\$str, 'last_uri'); + is($str, "${next_base}/4.xhtml", "Correct last_uri ($next_type)"); + + for my $i (1 .. 5) { + ok(-e "$cwd/$i.jpg", + "$i.jpg was downloaded successfully ($next_type)"); + } + + $exit = $test->run( + chdir => $cwd, + ); + + ok(($exit >> 8) == 1, 'Second run: return 1 (no new images loaded)'); + + isnt($test->stdout, q{}, 'Second run: Non-empty stdout'); + is ($test->stderr, q{}, 'Second run: Empty stderr'); +} diff --git a/test/60-comirror-setup.t b/test/60-comirror-setup.t new file mode 100755 index 0000000..5f61969 --- /dev/null +++ b/test/60-comirror-setup.t @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; +use Cwd; +use Test::More tests => 9; +use Test::Cmd; + +my $test = Test::Cmd->new( prog => 'bin/comirror-setup', workdir => q{} ); +my $cwd = $test->workdir(); + +my $next_base = 'file://' . getcwd() . '/test/next-loop'; +my ($str, $exit); +my @links; + +ok($test, 'Create Test::Cmd object'); + +$exit = $test->run( + chdir => $cwd +); + +ok($exit != 0, 'Not enough arguments: non-zero return'); + +is ($test->stdout, q{}, 'Not enough arguments: Nothing to stdout'); +isnt($test->stderr, q{}, 'Not enough arguments: Something to stderr'); + +for my $i (1 .. 5) { + push(@links, "${next_base}/${i}.xhtml"); +} + +$exit = $test->run( + chdir => $cwd, + args => join(q{ }, @links[0, 1, 3]), +); + +ok($exit == 0, 'Correct usage: return zero'); + +isnt($test->stdout, q{}, 'Correct usage: Something to stdout'); +is ($test->stderr, q{}, 'Correct usage: Nothing to stderr'); + +$test->read(\$str, 'last_uri'); +is($str, "$links[0]\n", 'Correct last_uri'); + +$test->read(\$str, 'image_re'); +is($str, "${next_base}/.+\n", 'Correct image_re'); diff --git a/test/next-loop/1.jpg b/test/next-loop/1.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-loop/1.xhtml b/test/next-loop/1.xhtml new file mode 100644 index 0000000..c0efc65 --- /dev/null +++ b/test/next-loop/1.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-loop/2.jpg b/test/next-loop/2.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-loop/2.xhtml b/test/next-loop/2.xhtml new file mode 100644 index 0000000..60e57e1 --- /dev/null +++ b/test/next-loop/2.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-loop/3.jpg b/test/next-loop/3.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-loop/3.xhtml b/test/next-loop/3.xhtml new file mode 100644 index 0000000..97eadf4 --- /dev/null +++ b/test/next-loop/3.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-loop/4.jpg b/test/next-loop/4.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-loop/4.xhtml b/test/next-loop/4.xhtml new file mode 100644 index 0000000..b0cf520 --- /dev/null +++ b/test/next-loop/4.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-loop/5.jpg b/test/next-loop/5.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-loop/5.xhtml b/test/next-loop/5.xhtml new file mode 100644 index 0000000..86ff9e8 --- /dev/null +++ b/test/next-loop/5.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-none/1.jpg b/test/next-none/1.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-none/1.xhtml b/test/next-none/1.xhtml new file mode 100644 index 0000000..c0efc65 --- /dev/null +++ b/test/next-none/1.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-none/2.jpg b/test/next-none/2.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-none/2.xhtml b/test/next-none/2.xhtml new file mode 100644 index 0000000..60e57e1 --- /dev/null +++ b/test/next-none/2.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-none/3.jpg b/test/next-none/3.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-none/3.xhtml b/test/next-none/3.xhtml new file mode 100644 index 0000000..97eadf4 --- /dev/null +++ b/test/next-none/3.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-none/4.jpg b/test/next-none/4.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-none/4.xhtml b/test/next-none/4.xhtml new file mode 100644 index 0000000..b0cf520 --- /dev/null +++ b/test/next-none/4.xhtml @@ -0,0 +1,14 @@ + + + + + + + +
+ + Next => +
+ + diff --git a/test/next-none/5.jpg b/test/next-none/5.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/next-none/5.xhtml b/test/next-none/5.xhtml new file mode 100644 index 0000000..41012d9 --- /dev/null +++ b/test/next-none/5.xhtml @@ -0,0 +1,13 @@ + + + + + + + +
+ +
+ + -- cgit v1.2.3