@@ -156,12 +156,12 @@ func TestPRStatus_reviewsAndChecks(t *testing.T) {
156156 }
157157}
158158
159- func TestPRStatus_closedMerged (t * testing.T ) {
159+ func TestPRStatus_currentBranch_showTheMostRecentPR (t * testing.T ) {
160160 initBlankContext ("OWNER/REPO" , "blueberries" )
161161 http := initFakeHTTP ()
162162 http .StubRepoResponse ("OWNER" , "REPO" )
163163
164- jsonFile , _ := os .Open ("../test/fixtures/prStatusClosedMerged .json" )
164+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranch .json" )
165165 defer jsonFile .Close ()
166166 http .StubResponse (200 , jsonFile )
167167
@@ -170,25 +170,30 @@ func TestPRStatus_closedMerged(t *testing.T) {
170170 t .Errorf ("error running command `pr status`: %v" , err )
171171 }
172172
173- expected := [] string {
174- "- Checks passing - Changes requested" ,
175- "- Closed" ,
176- "- Merged" ,
173+ expectedLine := regexp . MustCompile ( `#10 Blueberries are certainly a good fruit \[blueberries\]` )
174+ if ! expectedLine . MatchString ( output . String ()) {
175+ t . Errorf ( "output did not match regexp /%s/ \n > output \n %s \n " , expectedLine , output )
176+ return
177177 }
178178
179- for _ , line := range expected {
180- if ! strings .Contains (output .String (), line ) {
181- t .Errorf ("output did not contain %q: %q" , line , output .String ())
179+ unexpectedLines := []* regexp.Regexp {
180+ regexp .MustCompile (`#9 Blueberries are a good fruit \[blueberries\] - Merged` ),
181+ regexp .MustCompile (`#8 Blueberries are probably a good fruit \[blueberries\] - Closed` ),
182+ }
183+ for _ , r := range unexpectedLines {
184+ if r .MatchString (output .String ()) {
185+ t .Errorf ("output unexpectedly match regexp /%s/\n > output\n %s\n " , r , output )
186+ return
182187 }
183188 }
184189}
185190
186- func TestPRStatus_currentBranch_showTheMostRecentPR (t * testing.T ) {
191+ func TestPRStatus_currentBranch_Closed (t * testing.T ) {
187192 initBlankContext ("OWNER/REPO" , "blueberries" )
188193 http := initFakeHTTP ()
189194 http .StubRepoResponse ("OWNER" , "REPO" )
190195
191- jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranch .json" )
196+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchClosed .json" )
192197 defer jsonFile .Close ()
193198 http .StubResponse (200 , jsonFile )
194199
@@ -197,21 +202,31 @@ func TestPRStatus_currentBranch_showTheMostRecentPR(t *testing.T) {
197202 t .Errorf ("error running command `pr status`: %v" , err )
198203 }
199204
200- expectedLine := regexp .MustCompile (`#10 Blueberries are certainly a good fruit \[blueberries\]` )
205+ expectedLine := regexp .MustCompile (`#8 Blueberries are a good fruit \[blueberries\] - Closed ` )
201206 if ! expectedLine .MatchString (output .String ()) {
202207 t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , expectedLine , output )
203208 return
204209 }
210+ }
205211
206- unexpectedLines := []* regexp.Regexp {
207- regexp .MustCompile (`#9 Blueberries are a good fruit \[blueberries\] - Merged` ),
208- regexp .MustCompile (`#8 Blueberries are probably a good fruit \[blueberries\] - Closed` ),
212+ func TestPRStatus_currentBranch_Merged (t * testing.T ) {
213+ initBlankContext ("OWNER/REPO" , "blueberries" )
214+ http := initFakeHTTP ()
215+ http .StubRepoResponse ("OWNER" , "REPO" )
216+
217+ jsonFile , _ := os .Open ("../test/fixtures/prStatusCurrentBranchMerged.json" )
218+ defer jsonFile .Close ()
219+ http .StubResponse (200 , jsonFile )
220+
221+ output , err := RunCommand (prStatusCmd , "pr status" )
222+ if err != nil {
223+ t .Errorf ("error running command `pr status`: %v" , err )
209224 }
210- for _ , r := range unexpectedLines {
211- if r . MatchString ( output . String ()) {
212- t . Errorf ( " output unexpectedly match regexp /%s/ \n > output \n %s \n " , r , output )
213- return
214- }
225+
226+ expectedLine := regexp . MustCompile ( `#8 Blueberries are a good fruit \[blueberries\] - Merged` )
227+ if ! expectedLine . MatchString ( output . String ()) {
228+ t . Errorf ( "output did not match regexp /%s/ \n > output \n %s \n " , expectedLine , output )
229+ return
215230 }
216231}
217232
0 commit comments