@@ -189,6 +189,27 @@ func TestPRStatus_currentBranch_showTheMostRecentPR(t *testing.T) {
189189 }
190190}
191191
192+ func TestPRStatus_currentBranch_defaultBranch (t * testing.T ) {
193+ initBlankContext ("" , "OWNER/REPO" , "blueberries" )
194+ http := initFakeHTTP ()
195+ http .StubRepoResponseWithDefaultBranch ("OWNER" , "REPO" , "blueberries" )
196+
197+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranch.json" )
198+ defer jsonFile .Close ()
199+ http .StubResponse (200 , jsonFile )
200+
201+ output , err := RunCommand (prStatusCmd , "pr status" )
202+ if err != nil {
203+ t .Errorf ("error running command `pr status`: %v" , err )
204+ }
205+
206+ expectedLine := regexp .MustCompile (`#10 Blueberries are certainly a good fruit \[blueberries\]` )
207+ if ! expectedLine .MatchString (output .String ()) {
208+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , expectedLine , output )
209+ return
210+ }
211+ }
212+
192213func TestPRStatus_currentBranch_Closed (t * testing.T ) {
193214 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
194215 http := initFakeHTTP ()
@@ -210,6 +231,27 @@ func TestPRStatus_currentBranch_Closed(t *testing.T) {
210231 }
211232}
212233
234+ func TestPRStatus_currentBranch_Closed_defaultBranch (t * testing.T ) {
235+ initBlankContext ("" , "OWNER/REPO" , "blueberries" )
236+ http := initFakeHTTP ()
237+ http .StubRepoResponseWithDefaultBranch ("OWNER" , "REPO" , "blueberries" )
238+
239+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchClosed.json" )
240+ defer jsonFile .Close ()
241+ http .StubResponse (200 , jsonFile )
242+
243+ output , err := RunCommand (prStatusCmd , "pr status" )
244+ if err != nil {
245+ t .Errorf ("error running command `pr status`: %v" , err )
246+ }
247+
248+ expectedLine := regexp .MustCompile (`There is no pull request associated with \[blueberries\]` )
249+ if ! expectedLine .MatchString (output .String ()) {
250+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , expectedLine , output )
251+ return
252+ }
253+ }
254+
213255func TestPRStatus_currentBranch_Merged (t * testing.T ) {
214256 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
215257 http := initFakeHTTP ()
@@ -231,6 +273,27 @@ func TestPRStatus_currentBranch_Merged(t *testing.T) {
231273 }
232274}
233275
276+ func TestPRStatus_currentBranch_Merged_defaultBranch (t * testing.T ) {
277+ initBlankContext ("" , "OWNER/REPO" , "blueberries" )
278+ http := initFakeHTTP ()
279+ http .StubRepoResponseWithDefaultBranch ("OWNER" , "REPO" , "blueberries" )
280+
281+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchMerged.json" )
282+ defer jsonFile .Close ()
283+ http .StubResponse (200 , jsonFile )
284+
285+ output , err := RunCommand (prStatusCmd , "pr status" )
286+ if err != nil {
287+ t .Errorf ("error running command `pr status`: %v" , err )
288+ }
289+
290+ expectedLine := regexp .MustCompile (`There is no pull request associated with \[blueberries\]` )
291+ if ! expectedLine .MatchString (output .String ()) {
292+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , expectedLine , output )
293+ return
294+ }
295+ }
296+
234297func TestPRStatus_blankSlate (t * testing.T ) {
235298 initBlankContext ("" , "OWNER/REPO" , "blueberries" )
236299 http := initFakeHTTP ()
0 commit comments