7 use File::Spec (); # catdir
9 use Test::More tests => 43;
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';
30 local $ENV{GIT_EXEC_PATH};
31 local $ENV{PATH} = 't/bin';
36 is $@, '', "App::Rgit->new(): no git, no GIT_EXEC_PATH: doesn't croak";
37 isa_ok $res, 'App::Rgit',
38 'App::Rgit->new(): no git, no GIT_EXEC_PATH: returns object';
41 local $ENV{GIT_EXEC_PATH} = 't/bin/git';
46 is $@, '', "App::Rgit->new(): no git: doesn't croak";
47 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no git: returns object';
55 like $@, qr/Couldn't find a proper git executable/,
56 'App::Rgit->new(): wrong git: croaks';
64 is $@, '', "App::Rgit->new(): no cmd: doesn't croak";
65 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no cmd: returns object';
74 is $@, '', "App::Rgit->new(): no args: doesn't croak";
75 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no args: returns object';
84 is $@, '', '$ar->new(): no args: doesn\'t croak';
85 isa_ok $res, 'App::Rgit', '$ar->new(): no args: returns object';
87 use App::Rgit::Command;
90 App::Rgit::Command::Once->App::Rgit::Command::new(
94 like $@, qr!Command dongs should be executed as a App::Rgit::Command::Each!,
95 'App::Rgit::Command::Once->App::Rgit::Command::new(cmd => "dongs"): croaks';
99 push @{'App::Rgit::Test::Foo::ISA'}, 'App::Rgit::Command::Once';
102 App::Rgit::Test::Foo->App::Rgit::Command::new(
106 is $@, '', "App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version'): doesn't croak";
107 isa_ok $res, 'App::Rgit::Test::Foo', "App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version'): returns object";
110 App::Rgit::Command->action('version')
113 "App::Rgit::Command->action('version'): doesn't croak";
114 is $res, 'App::Rgit::Command::Once',
115 "App::Rgit::Command->action('version'): returns class";
118 App::Rgit::Command->new(
123 "App::Rgit::Command->action(): doesn't croak";
124 is $res, 'App::Rgit::Command::Once',
125 'App::Rgit::Command->action(): returns class';
128 App::Rgit::Command->action()
130 is $@, '', "App::Rgit::Command->action(): no cmd: doesn't croak";
131 is $res, undef, 'App::Rgit::Command->action(); no cmd: returns undef';
134 App::Rgit::Command::action()
136 is $@, '', "undef->App::Rgit::Command::action(): no cmd: doesn't croak";
137 is $res, undef, 'undef->App::Rgit::Command::action(); no cmd: returns undef';
140 my $obj = bless { }, 'App::Rgit::Test::Monkey';
141 $obj->App::Rgit::Command::action()
144 "App::Rgit::Test::Monkey->App::Rgit::Command::action(): no cmd: doesn't croak";
146 'App::Rgit::Test::Monkey->App::Rgit::Command::action(); no cmd: returns undef';
149 App::Rgit::Command->action(
150 beer => 'App::Rgit::Test::Pub'
154 "App::Rgit::Command->action(beer => 'App::Rgit::Test::Pub'): doesn't croak";
155 is $res, 'App::Rgit::Test::Pub',
156 "App::Rgit::Command->action(beer => 'App::Rgit::Test::Pub'): returns class";
159 App::Rgit::Command->action('beer')
162 "App::Rgit::Command->action('beer'): doesn't croak";
163 is $res, 'App::Rgit::Test::Pub',
164 "App::Rgit::Command->action('beer'): returns class";
167 App::Rgit::Command->new(
171 like $@, qr!Couldn't load App::Rgit::Test::Pub:!,
172 'App::Rgit::Command->new(cmd => "pub"): croaks';
174 use App::Rgit::Config;
176 my $arc = App::Rgit::Config->new(root => 't', git => 't/bin/git');
178 $res = eval { $arc->repos };
179 is $@, '', '$arc->repos: doesn\'t croak';
180 is_deeply $res, [ ], '$arc->repos: found nothing';
182 $res = eval { $arc->repos };
183 is $@, '', '$arc->repos: doesn\'t croak';
184 is_deeply $res, [ ], '$arc->repos: cached ok';
186 use App::Rgit::Repository;
189 my $t = File::Spec->catdir($cwd, 't');
190 chdir $t or die "chdir($t): $!";
193 App::Rgit::Repository->new();
195 is $@, '', "App::Rgit::Repository->new: no dir: doesn't croak";
196 is $res, undef, 'App::Rgit::Repository->new: no dir: returns undef';
199 App::Rgit::Repository->new(
204 "App::Rgit::Repository->new: no dir, fake: doesn't croak";
205 isa_ok $res, 'App::Rgit::Repository',
206 'App::Rgit::Repository->new: no dir, fake: returns object';
208 chdir $cwd or die "chdir($cwd): $!";
211 App::Rgit::Repository->new(dir => 't', fake => 1)
214 "App::Rgit::Repository->new: relative dir, fake: doesn't croak";
215 isa_ok $res, 'App::Rgit::Repository',
216 'App::Rgit::Repository->new: relative dir, fake: returns object';