[pkg-perl-tools] 01/06: Test GitHub pull request workflow

Alex Muntada alexm-guest at moszumanska.debian.org
Mon Oct 31 17:14:54 UTC 2016


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

alexm-guest pushed a commit to branch forward-github-pr
in repository pkg-perl-tools.

commit de0f9196f657d373fda2ca5f62b7c1f3366e9932
Author: Alex Muntada <alexm at alexm.org>
Date:   Sat May 28 21:10:28 2016 +0200

    Test GitHub pull request workflow
---
 t/dummy.txt.patch |  7 +++++++
 t/github.t        | 44 ++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/t/dummy.txt.patch b/t/dummy.txt.patch
new file mode 100644
index 0000000..459a405
--- /dev/null
+++ b/t/dummy.txt.patch
@@ -0,0 +1,7 @@
+diff --git a/dummy.txt b/dummy.txt
+index a5304af..358fe0a 100644
+--- a/dummy.txt
++++ b/dummy.txt
+@@ -1 +1,2 @@
+ Feel free to patch this file.
++This line is added.
diff --git a/t/github.t b/t/github.t
index 1cd55f3..f80b780 100644
--- a/t/github.t
+++ b/t/github.t
@@ -4,20 +4,56 @@ use strict;
 use warnings;
 
 use Test::More;
+use File::Temp qw(tempdir);
 
 BEGIN {
     plan skip_all
-        => "GitHub tests require DPT_GITHUB_OAUTH token and Net::GitHub"
+        => "GitHub tests require DPT_GITHUB_OAUTH token,"
+         . " Net::GitHub and Git::Repository"
         unless $ENV{DPT_GITHUB_OAUTH}
         and $ENV{DPT_GITHUB_OAUTH} =~ /^\w+$/
-        and eval "use Net::GitHub; 1";
+        and eval "use Net::GitHub; 1"
+        and eval "use Git::Repository; 1";
 }
 
 my $gh = new_ok('Net::GitHub::V3', [
     access_token => $ENV{DPT_GITHUB_OAUTH},
 ]);
 
-my $login = 'debian-perl';
-is( $gh->user->show($login)->{login}, $login, $login );
+my $orgname = 'pkg-perl-tools';
+is( $gh->user->show($orgname)->{login}, $orgname, $orgname );
+
+my $repos = $gh->repos;
+$repos->set_default_user_repo('alexm', 'pkg-perl-dummy');
+my $fork = $repos->create_fork($orgname);
+isnt( $fork, undef, 'create fork' );
+
+my $workdir = tempdir( CLEANUP => 1 );
+Git::Repository->run(
+    clone => "git\@github.com:$orgname/pkg-perl-dummy.git",
+    $workdir,
+    { quiet => 1 },
+);
+my $r = Git::Repository->new( work_tree => $workdir, { quiet => 1 } );
+$r->run( checkout => '-b', "test-branch-$^T" );
+
+my $patched = system( "cat t/dummy.txt.patch | (cd $workdir && patch -p1)" ) == 0;
+ok( $patched, 'patch dummy.txt' );
+
+$r->run( add => '.' );
+$r->run( commit => '-m', "Test patch $^T" );
+$r->run( push => 'origin', "test-branch-$^T" );
+
+my $pull_request = $gh->pull_request;
+$pull_request->set_default_user_repo('alexm', 'pkg-perl-dummy');
+my $pull = $pull_request->create_pull({
+    title => "Test patch $^T",
+    body  => "Testing pull requests from pkg-perl-tools.",
+    head  => "$orgname:test-branch-$^T",
+    base  => "master",
+});
+isnt( $pull, undef, 'create pull request' );
+
+diag $pull->{html_url};
 
 done_testing();

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



More information about the Pkg-perl-cvs-commits mailing list