From 1932c998cac488d6ba27789fea56bcf3a554a35c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 4 Mar 2011 12:22:22 +0100 Subject: Switch from Makefile to Build.PL --- t/60-comirror-setup.t | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 t/60-comirror-setup.t (limited to 't/60-comirror-setup.t') diff --git a/t/60-comirror-setup.t b/t/60-comirror-setup.t new file mode 100755 index 0000000..a487185 --- /dev/null +++ b/t/60-comirror-setup.t @@ -0,0 +1,62 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; +use Cwd; +use Test::More tests => 18; +use Test::Cmd; + +my $test; + +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}"); + } +} + +for my $test_type (qw/loop unicroak/) { + + $test = Test::Cmd->new( prog => 'bin/comirror-setup', workdir => q{} ); + my $cwd = $test->workdir(); + + my $next_base = 'file://' . getcwd() . "/t/next-${test_type}"; + 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 => '--batch ' . 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'); + + check_key('state', 'uri', $links[0]); + + check_key('conf', 'image_re', "${next_base}/.+"); + +} -- cgit v1.2.3