]> git.vpit.fr Git - perl/modules/rgit.git/blobdiff - t/15-failures.t
Throughly test App::Rgit::Command::action
[perl/modules/rgit.git] / t / 15-failures.t
index 6b823fe9dc5ae425f816b77d1c19c21b59d43a39..46d2d320806aa01729d9c4e61c2a06c144cd97ed 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 17;
+use Test::More tests => 30;
 
 use App::Rgit;
 
@@ -43,3 +43,37 @@ isa_ok($res, 'App::Rgit', '$ar->new(): no args: returns an object');
 $res = eval { App::Rgit::new(undef, root => 't/repos', git => 't/bin/git', cmd => 'version'); };
 is($@,       '',         'undef->App::Rgit::new(): no args: does not croak');
 isa_ok($res, 'App::Rgit','undef->App::Rgit::new(): no args: returns an object');
+
+use App::Rgit::Command;
+
+eval { App::Rgit::Command::Once->App::Rgit::Command::new(cmd => 'dongs') };
+like($@, qr!Command\s+dongs\s+should\s+be\s+executed\s+as\s+a\s+App::Rgit::Command::Each!, 'App::Rgit::Command::Once->App::Rgit::Command::new(cmd => "dongs"): croaks');
+
+{
+ no strict 'refs';
+ push @{'App::Rgit::Test::Foo::ISA'}, 'App::Rgit::Command::Once';
+}
+$res = eval { App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version') };
+is($@, '', 'App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => "version"): does not croak');
+isa_ok($res, 'App::Rgit::Test::Foo', 'App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => "version"): returns valid object');
+
+$res = eval { App::Rgit::Command->action('version') };
+is($@,   '', 'App::Rgit::Command->action("version"): does not croak');
+is($res, 'App::Rgit::Command::Once', 'App::Rgit::Command->action("version"): returns valid object');
+
+$res = eval { App::Rgit::Command->new(cmd => 'version')->action() };
+is($@,   '', 'App::Rgit::Command->action(): does not croak');
+is($res, 'App::Rgit::Command::Once', 'App::Rgit::Command->action(): returns valid object');
+
+$res = eval { App::Rgit::Command->action() };
+is($@,   '',    'App::Rgit::Command->action(): no cmd: does not croak');
+is($res, undef, 'App::Rgit::Command->action(); no cmd: returns undef');
+
+$res = eval { App::Rgit::Command::action() };
+is($@,   '',    'undef->App::Rgit::Command::action(): no cmd: does not croak');
+is($res, undef, 'undef->App::Rgit::Command::action(); no cmd: returns undef');
+
+$res = bless { }, 'App::Rgit::Test::Monkey';
+$res = eval { $res->App::Rgit::Command::action() };
+is($@,   '',    'App::Rgit::Test::Monkey->App::Rgit::Command::action(): no cmd: does not croak');
+is($res, undef, 'App::Rgit::Test::Monkey->App::Rgit::Command::action(); no cmd: returns undef');