]> git.vpit.fr Git - perl/modules/rgit.git/blob - t/15-failures.t
6b823fe9dc5ae425f816b77d1c19c21b59d43a39
[perl/modules/rgit.git] / t / 15-failures.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 17;
7
8 use App::Rgit;
9
10 local $SIG{__WARN__} = sub { die @_ };
11
12 eval { App::Rgit->new(qw/foo bar baz/) };
13 like($@, qr!Optional\s+arguments\s+must\s+be\s+passed\s+as\s+keys?\s*/\s*values?\s+pairs?!, 'App::Rgit->new(even): croaks');
14
15 my $res = eval { App::Rgit->new() };
16 is($@,   '',    'App::Rgit->new(): no root: does not croak');
17 is($res, undef, 'App::Rgit->new(): no root: returns undef');
18
19 $res = eval { App::Rgit->new(root => $0) };
20 is($@,   '',    'App::Rgit->new(): wrong root: does not croak');
21 is($res, undef, 'App::Rgit->new(): wrong root: returns undef');
22
23 $res = eval { App::Rgit->new(root => 't/repos') };
24 is($@,   '',    'App::Rgit->new(): no git: does not croak');
25 is($res, undef, 'App::Rgit->new(): no git: returns undef');
26
27 $res = eval { App::Rgit->new(root => 't/repos', git => $0) };
28 is($@,   '',    'App::Rgit->new(): wrong git: does not croak');
29 is($res, undef, 'App::Rgit->new(): wrong git: returns undef');
30
31 $res = eval { App::Rgit->new(root => 't/repos', git => 't/bin/git') };
32 is($@,       '',          'App::Rgit->new(): no cmd: does not croak');
33 isa_ok($res, 'App::Rgit', 'App::Rgit->new(): no cmd: returns an object');
34
35 $res = eval { App::Rgit->new(root => 't/repos', git => 't/bin/git', cmd => 'version'); };
36 is($@,       '',          'App::Rgit->new(): no args: does not croak');
37 isa_ok($res, 'App::Rgit', 'App::Rgit->new(): no args: returns an object');
38
39 $res = eval { $res->new(root => 't/repos', git => 't/bin/git', cmd => 'version'); };
40 is($@,       '',          '$ar->new(): no args: does not croak');
41 isa_ok($res, 'App::Rgit', '$ar->new(): no args: returns an object');
42
43 $res = eval { App::Rgit::new(undef, root => 't/repos', git => 't/bin/git', cmd => 'version'); };
44 is($@,       '',         'undef->App::Rgit::new(): no args: does not croak');
45 isa_ok($res, 'App::Rgit','undef->App::Rgit::new(): no args: returns an object');