]> git.vpit.fr Git - perl/modules/rgit.git/blobdiff - t/15-failures.t
Make App::Rgit::Config->new discover the git executable itself
[perl/modules/rgit.git] / t / 15-failures.t
index 765298955f82ce29d1857ff945a9d983ed6a2b45..0e31edd4382297098cce2fd4f640905b766aa748 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use Cwd        (); # cwd
 use File::Spec (); # catdir
 
-use Test::More tests => 42;
+use Test::More tests => 43;
 
 use App::Rgit;
 
@@ -27,12 +27,24 @@ is $@,   '',    "App::Rgit->new(): wrong root: doesn't croak";
 is $res, undef, 'App::Rgit->new(): wrong root: returns undef';
 
 $res = eval {
+ local $ENV{GIT_EXEC_PATH};
+ local $ENV{PATH} = 't/bin';
  App::Rgit->new(
   root => 't',
  );
 };
-is $@,   '',    "App::Rgit->new(): no git: doesn't croak";
-is $res, undef, 'App::Rgit->new(): no git: returns undef';
+is     $@,   '',   "App::Rgit->new(): no git, no GIT_EXEC_PATH: doesn't croak";
+isa_ok $res, 'App::Rgit',
+                   'App::Rgit->new(): no git, no GIT_EXEC_PATH: returns object';
+
+$res = eval {
+ local $ENV{GIT_EXEC_PATH} = 't/bin/git';
+ App::Rgit->new(
+  root => 't',
+ );
+};
+is     $@,   '',          "App::Rgit->new(): no git: doesn't croak";
+isa_ok $res, 'App::Rgit', 'App::Rgit->new(): no git: returns object';
 
 $res = eval {
  App::Rgit->new(
@@ -40,8 +52,8 @@ $res = eval {
   git  => $0,
  );
 };
-is $@,   '',    "App::Rgit->new(): wrong git: doesn't croak";
-is $res, undef, 'App::Rgit->new(): wrong git: returns undef';
+like $@, qr/Couldn't find a proper git executable/,
+                                          'App::Rgit->new(): wrong git: croaks';
 
 $res = eval {
  App::Rgit->new(