7 use File::Spec (); # catdir
9 use Test::More tests => 42;
13 local $SIG{__WARN__} = sub { die @_ };
18 is $@, '', "App::Rgit->new(): no root: doesn't croak";
19 is $res, undef, 'App::Rgit->new(): no root: returns undef';
26 is $@, '', "App::Rgit->new(): wrong root: doesn't croak";
27 is $res, undef, 'App::Rgit->new(): wrong root: returns undef';
34 is $@, '', "App::Rgit->new(): no git: doesn't croak";
35 is $res, undef, 'App::Rgit->new(): no git: returns undef';
43 is $@, '', "App::Rgit->new(): wrong git: doesn't croak";
44 is $res, undef, 'App::Rgit->new(): wrong git: returns undef';
52 is $@, '', "App::Rgit->new(): no cmd: doesn't croak";
53 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no cmd: returns object';
62 is $@, '', "App::Rgit->new(): no args: doesn't croak";
63 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no args: returns object';
72 is $@, '', '$ar->new(): no args: doesn\'t croak';
73 isa_ok $res, 'App::Rgit', '$ar->new(): no args: returns object';
75 use App::Rgit::Command;
78 App::Rgit::Command::Once->App::Rgit::Command::new(
82 like $@, qr!Command dongs should be executed as a App::Rgit::Command::Each!,
83 'App::Rgit::Command::Once->App::Rgit::Command::new(cmd => "dongs"): croaks';
87 push @{'App::Rgit::Test::Foo::ISA'}, 'App::Rgit::Command::Once';
90 App::Rgit::Test::Foo->App::Rgit::Command::new(
94 is $@, '', "App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version'): doesn't croak";
95 isa_ok $res, 'App::Rgit::Test::Foo', "App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version'): returns object";
98 App::Rgit::Command->action('version')
101 "App::Rgit::Command->action('version'): doesn't croak";
102 is $res, 'App::Rgit::Command::Once',
103 "App::Rgit::Command->action('version'): returns class";
106 App::Rgit::Command->new(
111 "App::Rgit::Command->action(): doesn't croak";
112 is $res, 'App::Rgit::Command::Once',
113 'App::Rgit::Command->action(): returns class';
116 App::Rgit::Command->action()
118 is $@, '', "App::Rgit::Command->action(): no cmd: doesn't croak";
119 is $res, undef, 'App::Rgit::Command->action(); no cmd: returns undef';
122 App::Rgit::Command::action()
124 is $@, '', "undef->App::Rgit::Command::action(): no cmd: doesn't croak";
125 is $res, undef, 'undef->App::Rgit::Command::action(); no cmd: returns undef';
128 my $obj = bless { }, 'App::Rgit::Test::Monkey';
129 $obj->App::Rgit::Command::action()
132 "App::Rgit::Test::Monkey->App::Rgit::Command::action(): no cmd: doesn't croak";
134 'App::Rgit::Test::Monkey->App::Rgit::Command::action(); no cmd: returns undef';
137 App::Rgit::Command->action(
138 beer => 'App::Rgit::Test::Pub'
142 "App::Rgit::Command->action(beer => 'App::Rgit::Test::Pub'): doesn't croak";
143 is $res, 'App::Rgit::Test::Pub',
144 "App::Rgit::Command->action(beer => 'App::Rgit::Test::Pub'): returns class";
147 App::Rgit::Command->action('beer')
150 "App::Rgit::Command->action('beer'): doesn't croak";
151 is $res, 'App::Rgit::Test::Pub',
152 "App::Rgit::Command->action('beer'): returns class";
155 App::Rgit::Command->new(
159 like $@, qr!Couldn't load App::Rgit::Test::Pub:!,
160 'App::Rgit::Command->new(cmd => "pub"): croaks';
162 use App::Rgit::Config;
164 my $arc = App::Rgit::Config->new(root => 't', git => 't/bin/git');
166 $res = eval { $arc->repos };
167 is $@, '', '$arc->repos: doesn\'t croak';
168 is_deeply $res, [ ], '$arc->repos: found nothing';
170 $res = eval { $arc->repos };
171 is $@, '', '$arc->repos: doesn\'t croak';
172 is_deeply $res, [ ], '$arc->repos: cached ok';
174 use App::Rgit::Repository;
177 my $t = File::Spec->catdir($cwd, 't');
178 chdir $t or die "chdir($t): $!";
181 App::Rgit::Repository->new();
183 is $@, '', "App::Rgit::Repository->new: no dir: doesn't croak";
184 is $res, undef, 'App::Rgit::Repository->new: no dir: returns undef';
187 App::Rgit::Repository->new(
192 "App::Rgit::Repository->new: no dir, fake: doesn't croak";
193 isa_ok $res, 'App::Rgit::Repository',
194 'App::Rgit::Repository->new: no dir, fake: returns object';
196 chdir $cwd or die "chdir($cwd): $!";
199 App::Rgit::Repository->new(dir => 't', fake => 1)
202 "App::Rgit::Repository->new: relative dir, fake: doesn't croak";
203 isa_ok $res, 'App::Rgit::Repository',
204 'App::Rgit::Repository->new: relative dir, fake: returns object';