6 use Test::More tests => 17;
10 local $SIG{__WARN__} = sub { die @_ };
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');
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');
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');
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');
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');
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');
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');
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');
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');