summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/50-comirror.t19
-rwxr-xr-xtest/60-comirror-setup.t19
2 files changed, 31 insertions, 7 deletions
diff --git a/test/50-comirror.t b/test/50-comirror.t
index 3dc25b7..8ccb334 100755
--- a/test/50-comirror.t
+++ b/test/50-comirror.t
@@ -6,6 +6,19 @@ 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{} );
@@ -16,7 +29,8 @@ for my $next_type (qw/ loop none /) {
ok($test, "Create Test::Cmd object ($next_type)");
- $test->write('image_re', "${next_base}/.+");
+ $test->write('comirror.conf', "image_re\t${next_base}/.+\n");
+
$exit = $test->run(
chdir => $cwd,
args => "${next_base}/1.xhtml",
@@ -27,8 +41,7 @@ for my $next_type (qw/ loop none /) {
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)");
+ check_key($test, 'state', 'uri', "${next_base}/4.xhtml");
for my $i (1 .. 5) {
ok(-e "$cwd/$i.jpg",
diff --git a/test/60-comirror-setup.t b/test/60-comirror-setup.t
index 5f61969..3efdcaf 100755
--- a/test/60-comirror-setup.t
+++ b/test/60-comirror-setup.t
@@ -13,6 +13,19 @@ my $next_base = 'file://' . getcwd() . '/test/next-loop';
my ($str, $exit);
my @links;
+sub check_key {
+ my ($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}");
+ }
+}
+
ok($test, 'Create Test::Cmd object');
$exit = $test->run(
@@ -38,8 +51,6 @@ 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');
+check_key('state', 'uri', $links[0]);
-$test->read(\$str, 'image_re');
-is($str, "${next_base}/.+\n", 'Correct image_re');
+check_key('conf', 'image_re', "${next_base}/.+");