7 use File::Spec (); # catdir
9 use Test::More tests => 44;
13 local $SIG{__WARN__} = sub { die @_ };
19 is $@, '', "App::Rgit->new(): no root, no GIT_DIR: doesn't croak";
20 isa_ok $res,'App::Rgit','App::Rgit->new(): no root, no GIT_DIR: returns object';
23 local $ENV{GIT_DIR} = Cwd::cwd;
26 is $@, '', "App::Rgit->new(): no root: doesn't croak";
27 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no root: returns object';
34 like $@, qr/Invalid root directory/, 'App::Rgit->new(): wrong root: croaks';
37 local $ENV{GIT_EXEC_PATH};
38 local $ENV{PATH} = 't/bin';
43 is $@, '', "App::Rgit->new(): no git, no GIT_EXEC_PATH: doesn't croak";
44 isa_ok $res, 'App::Rgit',
45 'App::Rgit->new(): no git, no GIT_EXEC_PATH: returns object';
48 local $ENV{GIT_EXEC_PATH} = 't/bin/git';
53 is $@, '', "App::Rgit->new(): no git: doesn't croak";
54 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no git: returns object';
62 like $@, qr/Couldn't find a proper git executable/,
63 'App::Rgit->new(): wrong git: croaks';
71 is $@, '', "App::Rgit->new(): no cmd: doesn't croak";
72 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no cmd: returns object';
81 is $@, '', "App::Rgit->new(): no args: doesn't croak";
82 isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no args: returns object';
91 is $@, '', '$ar->new(): no args: doesn\'t croak';
92 isa_ok $res, 'App::Rgit', '$ar->new(): no args: returns object';
94 use App::Rgit::Command;
97 App::Rgit::Command::Once->App::Rgit::Command::new(
101 like $@, qr!Command dongs should be executed as a App::Rgit::Command::Each!,
102 'App::Rgit::Command::Once->App::Rgit::Command::new(cmd => "dongs"): croaks';
106 push @{'App::Rgit::Test::Foo::ISA'}, 'App::Rgit::Command::Once';
109 App::Rgit::Test::Foo->App::Rgit::Command::new(
113 is $@, '', "App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version'): doesn't croak";
114 isa_ok $res, 'App::Rgit::Test::Foo', "App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version'): returns object";
117 App::Rgit::Command->action('version')
120 "App::Rgit::Command->action('version'): doesn't croak";
121 is $res, 'App::Rgit::Command::Once',
122 "App::Rgit::Command->action('version'): returns class";
125 App::Rgit::Command->new(
130 "App::Rgit::Command->action(): doesn't croak";
131 is $res, 'App::Rgit::Command::Once',
132 'App::Rgit::Command->action(): returns class';
135 App::Rgit::Command->action()
137 is $@, '', "App::Rgit::Command->action(): no cmd: doesn't croak";
138 is $res, undef, 'App::Rgit::Command->action(); no cmd: returns undef';
141 App::Rgit::Command::action()
143 is $@, '', "undef->App::Rgit::Command::action(): no cmd: doesn't croak";
144 is $res, undef, 'undef->App::Rgit::Command::action(); no cmd: returns undef';
147 my $obj = bless { }, 'App::Rgit::Test::Monkey';
148 $obj->App::Rgit::Command::action()
151 "App::Rgit::Test::Monkey->App::Rgit::Command::action(): no cmd: doesn't croak";
153 'App::Rgit::Test::Monkey->App::Rgit::Command::action(); no cmd: returns undef';
156 App::Rgit::Command->action(
157 beer => 'App::Rgit::Test::Pub'
161 "App::Rgit::Command->action(beer => 'App::Rgit::Test::Pub'): doesn't croak";
162 is $res, 'App::Rgit::Test::Pub',
163 "App::Rgit::Command->action(beer => 'App::Rgit::Test::Pub'): returns class";
166 App::Rgit::Command->action('beer')
169 "App::Rgit::Command->action('beer'): doesn't croak";
170 is $res, 'App::Rgit::Test::Pub',
171 "App::Rgit::Command->action('beer'): returns class";
174 App::Rgit::Command->new(
178 like $@, qr!Couldn't load App::Rgit::Test::Pub:!,
179 'App::Rgit::Command->new(cmd => "pub"): croaks';
181 use App::Rgit::Config;
183 my $arc = App::Rgit::Config->new(root => 't', git => 't/bin/git');
185 $res = eval { $arc->repos };
186 is $@, '', '$arc->repos: doesn\'t croak';
187 is_deeply $res, [ ], '$arc->repos: found nothing';
189 $res = eval { $arc->repos };
190 is $@, '', '$arc->repos: doesn\'t croak';
191 is_deeply $res, [ ], '$arc->repos: cached ok';
193 use App::Rgit::Repository;
196 my $t = File::Spec->catdir($cwd, 't');
197 chdir $t or die "chdir($t): $!";
200 App::Rgit::Repository->new();
202 is $@, '', "App::Rgit::Repository->new: no dir: doesn't croak";
203 is $res, undef, 'App::Rgit::Repository->new: no dir: returns undef';
206 App::Rgit::Repository->new(
211 "App::Rgit::Repository->new: no dir, fake: doesn't croak";
212 isa_ok $res, 'App::Rgit::Repository',
213 'App::Rgit::Repository->new: no dir, fake: returns object';
215 chdir $cwd or die "chdir($cwd): $!";
218 App::Rgit::Repository->new(dir => 't', fake => 1)
221 "App::Rgit::Repository->new: relative dir, fake: doesn't croak";
222 isa_ok $res, 'App::Rgit::Repository',
223 'App::Rgit::Repository->new: relative dir, fake: returns object';