From: Vincent Pit Date: Mon, 6 Oct 2008 15:53:32 +0000 (+0200) Subject: Test directory handling of App::Rgit::Repository X-Git-Tag: v0.03~6 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Frgit.git;a=commitdiff_plain;h=8fdce8c3a7141c295beda7a77939df531cb8abcc Test directory handling of App::Rgit::Repository --- diff --git a/t/15-failures.t b/t/15-failures.t index 19b3995..c39407c 100644 --- a/t/15-failures.t +++ b/t/15-failures.t @@ -3,7 +3,10 @@ use strict; use warnings; -use Test::More tests => 38; +use Cwd qw/cwd/; +use File::Spec::Functions qw/catdir/; + +use Test::More tests => 44; use App::Rgit; @@ -97,3 +100,24 @@ 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'); +