diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-03-04 12:22:22 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-03-04 12:22:22 +0100 |
commit | 1932c998cac488d6ba27789fea56bcf3a554a35c (patch) | |
tree | 39304ac27f408d58095d07634fbba6520efd5d21 /t/50-comirror.t | |
parent | e1e7a58aa6983261757affa1b146d6ce20742a69 (diff) |
Switch from Makefile to Build.PL
Diffstat (limited to 't/50-comirror.t')
-rwxr-xr-x | t/50-comirror.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/t/50-comirror.t b/t/50-comirror.t new file mode 100755 index 0000000..6adc23c --- /dev/null +++ b/t/50-comirror.t @@ -0,0 +1,59 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; +use Cwd; +use Test::More tests => 26; +use Test::Cmd; + +sub check_key { + my ($test, $filetype, $key, $value) = @_; + my @lines; + $test->read(\@lines, "comirror.${filetype}"); + + if(grep { $_ eq "$key\t$value\n" } @lines) { + pass("${filetype}: ${key} = ${value}"); + } + else { + fail("${filetype}: ${key} = ${value}"); + } +} + +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() . "/t/next-${next_type}"; + my ($str, $exit); + + ok($test, "Create Test::Cmd object ($next_type)"); + + $test->write('comirror.conf', "image_re\t${next_base}/.+\n"); + + $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'); + + check_key($test, 'state', 'uri', "${next_base}/4.xhtml"); + + 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'); +} |