This is an automated email from the git hooks/post-receive script.

alexm-guest pushed a commit to branch master
in repository pkg-perl-tools.

commit 08d93497fe65ace31a791c65c75abbe4eeb361f4
Author: Alex Muntada <al...@alexm.org>
Date:   Sat Dec 3 19:00:41 2016 +0100

    Add test for failback feature in pull requests
---
 t/github.t | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/t/github.t b/t/github.t
index bfd075f..ee3e995 100644
--- a/t/github.t
+++ b/t/github.t
@@ -14,12 +14,14 @@ BEGIN {
         => "GitHub tests require DPT_GITHUB_OAUTH token,"
          . " a working Debian::PkgPerl::GitHub,"
          . " Debian::PkgPerl::Message,"
-         . " and Debian::PkgPerl::Patch"
+         . " Debian::PkgPerl::Patch,"
+         . " and Test::MockModule"
         unless $ENV{DPT_GITHUB_OAUTH}
         and $ENV{DPT_GITHUB_OAUTH} =~ /^\w+$/
         and eval { use Debian::PkgPerl::Patch; 1 }
         and eval { use Debian::PkgPerl::Message; 1 }
-        and eval { use Debian::PkgPerl::GitHub; 1 };
+        and eval { use Debian::PkgPerl::GitHub; 1 }
+        and eval { use Test::MockModule; 1 };
 }
 
 use Test::RequiresInternet ( 'github.com' => 22 );
@@ -43,10 +45,32 @@ my $msg = Debian::PkgPerl::Message->new(
     interactive => 0,
 );
 
-my $gh = new_ok( 'Debian::PkgPerl::GitHub', [ message => $msg ] );
+my $class = 'Debian::PkgPerl::GitHub';
 
-my $url = $gh->forward();
-isnt( $url, undef, 'pull request' );
-diag $url;
+subtest 'pull request' => sub {
+    my $gh = new_ok( $class, [ message => $msg ] );
+
+    my $url = $gh->forward();
+    isnt( $url, undef, 'successful pull request' );
+    diag $url;
+
+    done_testing();
+};
+
+subtest 'fallback' => sub {
+    my $mock = Test::MockModule->new($class);
+    $mock->mock( forward_patch_as_pull_request => sub { die 'mock' } );
+
+    my $gh = new_ok( $class, [
+        message  => $msg,
+        fallback => 1,
+    ]);
+
+    my $url = $gh->forward();
+    isnt( $url, undef, 'failed pull request' );
+    diag $url;
+
+    done_testing();
+};
 
 done_testing();

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to