@@ -77,6 +77,7 @@ func TestPRStatus(t *testing.T) {
7777 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
7878 http := initFakeHTTP ()
7979 http .StubRepoResponse ("OWNER" , "REPO" )
80+ http .StubRepoResponse ("OWNER" , "REPO" )
8081
8182 jsonFile , _ := os .Open ("../test/fixtures/prStatus.json" )
8283 defer jsonFile .Close ()
@@ -105,6 +106,7 @@ func TestPRStatus_fork(t *testing.T) {
105106 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
106107 http := initFakeHTTP ()
107108 http .StubForkedRepoResponse ("OWNER/REPO" , "PARENT/REPO" )
109+ http .StubForkedRepoResponse ("OWNER/REPO" , "PARENT/REPO" )
108110
109111 jsonFile , _ := os .Open ("../test/fixtures/prStatusFork.json" )
110112 defer jsonFile .Close ()
@@ -135,6 +137,7 @@ func TestPRStatus_reviewsAndChecks(t *testing.T) {
135137 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
136138 http := initFakeHTTP ()
137139 http .StubRepoResponse ("OWNER" , "REPO" )
140+ http .StubRepoResponse ("OWNER" , "REPO" )
138141
139142 jsonFile , _ := os .Open ("../test/fixtures/prStatusChecks.json" )
140143 defer jsonFile .Close ()
@@ -162,6 +165,7 @@ func TestPRStatus_currentBranch_showTheMostRecentPR(t *testing.T) {
162165 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
163166 http := initFakeHTTP ()
164167 http .StubRepoResponse ("OWNER" , "REPO" )
168+ http .StubRepoResponse ("OWNER" , "REPO" )
165169
166170 jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranch.json" )
167171 defer jsonFile .Close ()
@@ -190,10 +194,33 @@ func TestPRStatus_currentBranch_showTheMostRecentPR(t *testing.T) {
190194 }
191195}
192196
197+ func TestPRStatus_currentBranch_defaultBranch (t * testing.T ) {
198+ initBlankContext ("" , "OWNER/REPO" , "blueberries" )
199+ http := initFakeHTTP ()
200+ http .StubRepoResponseWithDefaultBranch ("OWNER" , "REPO" , "blueberries" )
201+ http .StubRepoResponse ("OWNER" , "REPO" )
202+
203+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranch.json" )
204+ defer jsonFile .Close ()
205+ http .StubResponse (200 , jsonFile )
206+
207+ output , err := RunCommand (prStatusCmd , "pr status" )
208+ if err != nil {
209+ t .Errorf ("error running command `pr status`: %v" , err )
210+ }
211+
212+ expectedLine := regexp .MustCompile (`#10 Blueberries are certainly a good fruit \[blueberries\]` )
213+ if ! expectedLine .MatchString (output .String ()) {
214+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , expectedLine , output )
215+ return
216+ }
217+ }
218+
193219func TestPRStatus_currentBranch_Closed (t * testing.T ) {
194220 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
195221 http := initFakeHTTP ()
196222 http .StubRepoResponse ("OWNER" , "REPO" )
223+ http .StubRepoResponse ("OWNER" , "REPO" )
197224
198225 jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchClosed.json" )
199226 defer jsonFile .Close ()
@@ -211,10 +238,33 @@ func TestPRStatus_currentBranch_Closed(t *testing.T) {
211238 }
212239}
213240
241+ func TestPRStatus_currentBranch_Closed_defaultBranch (t * testing.T ) {
242+ initBlankContext ("" , "OWNER/REPO" , "blueberries" )
243+ http := initFakeHTTP ()
244+ http .StubRepoResponseWithDefaultBranch ("OWNER" , "REPO" , "blueberries" )
245+ http .StubRepoResponse ("OWNER" , "REPO" )
246+
247+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchClosed.json" )
248+ defer jsonFile .Close ()
249+ http .StubResponse (200 , jsonFile )
250+
251+ output , err := RunCommand (prStatusCmd , "pr status" )
252+ if err != nil {
253+ t .Errorf ("error running command `pr status`: %v" , err )
254+ }
255+
256+ expectedLine := regexp .MustCompile (`There is no pull request associated with \[blueberries\]` )
257+ if ! expectedLine .MatchString (output .String ()) {
258+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , expectedLine , output )
259+ return
260+ }
261+ }
262+
214263func TestPRStatus_currentBranch_Merged (t * testing.T ) {
215264 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
216265 http := initFakeHTTP ()
217266 http .StubRepoResponse ("OWNER" , "REPO" )
267+ http .StubRepoResponse ("OWNER" , "REPO" )
218268
219269 jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchMerged.json" )
220270 defer jsonFile .Close ()
@@ -232,10 +282,33 @@ func TestPRStatus_currentBranch_Merged(t *testing.T) {
232282 }
233283}
234284
285+ func TestPRStatus_currentBranch_Merged_defaultBranch (t * testing.T ) {
286+ initBlankContext ("" , "OWNER/REPO" , "blueberries" )
287+ http := initFakeHTTP ()
288+ http .StubRepoResponseWithDefaultBranch ("OWNER" , "REPO" , "blueberries" )
289+ http .StubRepoResponse ("OWNER" , "REPO" )
290+
291+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchMerged.json" )
292+ defer jsonFile .Close ()
293+ http .StubResponse (200 , jsonFile )
294+
295+ output , err := RunCommand (prStatusCmd , "pr status" )
296+ if err != nil {
297+ t .Errorf ("error running command `pr status`: %v" , err )
298+ }
299+
300+ expectedLine := regexp .MustCompile (`There is no pull request associated with \[blueberries\]` )
301+ if ! expectedLine .MatchString (output .String ()) {
302+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , expectedLine , output )
303+ return
304+ }
305+ }
306+
235307func TestPRStatus_blankSlate (t * testing.T ) {
236308 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
237309 http := initFakeHTTP ()
238310 http .StubRepoResponse ("OWNER" , "REPO" )
311+ http .StubRepoResponse ("OWNER" , "REPO" )
239312
240313 http .StubResponse (200 , bytes .NewBufferString (`
241314 { "data": {} }
0 commit comments