@@ -65,6 +65,49 @@ func TestPRCreate(t *testing.T) {
6565 eq (t , output .String (), "https://github.com/OWNER/REPO/pull/12\n " )
6666}
6767
68+ func TestPRCreate_withForking (t * testing.T ) {
69+ initBlankContext ("OWNER/REPO" , "feature" )
70+ http := initFakeHTTP ()
71+ http .StubRepoResponseWithPermission ("OWNER" , "REPO" , "READ" )
72+ http .StubResponse (200 , bytes .NewBufferString (`
73+ { "data": { "repository": { "forks": { "nodes": [
74+ ] } } } }
75+ ` ))
76+ http .StubResponse (200 , bytes .NewBufferString (`
77+ { "data": { "repository": { "pullRequests": { "nodes" : [
78+ ] } } } }
79+ ` ))
80+ http .StubResponse (200 , bytes .NewBufferString (`
81+ { "node_id": "NODEID",
82+ "name": "REPO",
83+ "owner": {"login": "myself"},
84+ "clone_url": "http://example.com",
85+ "created_at": "2008-02-25T20:21:40Z"
86+ }
87+ ` ))
88+ http .StubResponse (200 , bytes .NewBufferString (`
89+ { "data": { "createPullRequest": { "pullRequest": {
90+ "URL": "https://github.com/OWNER/REPO/pull/12"
91+ } } } }
92+ ` ))
93+
94+ cs , cmdTeardown := test .InitCmdStubber ()
95+ defer cmdTeardown ()
96+
97+ cs .Stub ("" ) // git config --get-regexp (determineTrackingBranch)
98+ cs .Stub ("" ) // git show-ref --verify (determineTrackingBranch)
99+ cs .Stub ("" ) // git status
100+ cs .Stub ("1234567890,commit 0\n 2345678901,commit 1" ) // git log
101+ cs .Stub ("" ) // git remote add
102+ cs .Stub ("" ) // git push
103+
104+ output , err := RunCommand (prCreateCmd , `pr create -t title -b body` )
105+ eq (t , err , nil )
106+
107+ eq (t , http .Requests [3 ].URL .Path , "/repos/OWNER/REPO/forks" )
108+ eq (t , output .String (), "https://github.com/OWNER/REPO/pull/12\n " )
109+ }
110+
68111func TestPRCreate_alreadyExists (t * testing.T ) {
69112 initBlankContext ("OWNER/REPO" , "feature" )
70113 http := initFakeHTTP ()
0 commit comments