X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F15-failures.t;h=296ffc843cfb144abcdd02969daf2090306d6323;hb=cbafb1b35c3e76d6a7cf1628c83f08e64d3f3c5c;hp=82f1409cc9ad19257ef53b1c3438671bb82b821f;hpb=eb3cdeba8301dba3e0444658b97c24e3a73fad84;p=perl%2Fmodules%2Frgit.git diff --git a/t/15-failures.t b/t/15-failures.t index 82f1409..296ffc8 100644 --- a/t/15-failures.t +++ b/t/15-failures.t @@ -3,7 +3,10 @@ use strict; use warnings; -use Test::More tests => 34; +use Cwd qw/cwd/; +use File::Spec::Functions qw/catdir/; + +use Test::More tests => 45; use App::Rgit; @@ -85,3 +88,39 @@ is($res, 'App::Rgit::Test::Pub', 'App::Rgit::Command->action("beer" => "App::Rgi $res = eval { App::Rgit::Command->action('beer') }; is($@, '', 'App::Rgit::Command->action("beer"): does not croak'); is($res, 'App::Rgit::Test::Pub', 'App::Rgit::Command->action("beer"): returns valid answer'); + +$res = eval { App::Rgit::Command->new(cmd => 'beer') }; +like($@, qr!Couldn't\s+load\s+App::Rgit::Test::Pub\s*:!, 'App::Rgit::Command->new(cmd => "pub"): croaks'); + +use App::Rgit::Config; + +my $arc = App::Rgit::Config->new(root => 't', git => 't/bin/git'); + +$res = eval { $arc->repos }; +is($@, '', '$arc->repos: does not croak'); +is_deeply($res, [ ], '$arc->repos: found nothing'); + +$res = eval { $arc->repos }; +is($@, '', '$arc->repos: does not croak'); +is_deeply($res, [ ], '$arc->repos: cached ok'); + +use App::Rgit::Repository; + +my $cwd = cwd; +my $t = catdir($cwd, 't'); +chdir $t or die "chdir($t): $!"; + +$res = eval { App::Rgit::Repository->new() }; +is($@, '', 'App::Rgit::Repository->new: no dir: does not croak'); +is($res, undef, 'App::Rgit::Repository->new: no dir: returns undef'); + +$res = eval { App::Rgit::Repository->new(fake => 1) }; +is($@, '', 'App::Rgit::Repository->new: no dir, fake: does not croak'); +isa_ok($res, 'App::Rgit::Repository', 'App::Rgit::Repository->new: no dir, fake: returns a valid object'); + +chdir $cwd or die "chdir($cwd): $!"; + +$res = eval { App::Rgit::Repository->new(dir => 't', fake => 1) }; +is($@, '', 'App::Rgit::Repository->new: relative dir, fake: does not croak'); +isa_ok($res, 'App::Rgit::Repository', 'App::Rgit::Repository->new: relative dir, fake: returns a valid object'); +