@@ -6,10 +6,10 @@ import (
66 "net/http"
77 "os/exec"
88 "reflect"
9- "regexp"
109 "strings"
1110 "testing"
1211
12+ "github.com/MakeNowJust/heredoc"
1313 "github.com/cli/cli/internal/ghrepo"
1414 "github.com/cli/cli/internal/run"
1515 "github.com/cli/cli/pkg/cmdutil"
@@ -76,23 +76,15 @@ func TestPRList(t *testing.T) {
7676 t .Fatal (err )
7777 }
7878
79- assert .Equal (t , `
80- Showing 3 of 3 open pull requests in OWNER/REPO
79+ assert .Equal (t , heredoc .Doc (`
8180
82- ` , output .Stderr ())
83-
84- lines := strings .Split (output .String (), "\n " )
85- res := []* regexp.Regexp {
86- regexp .MustCompile (`#32.*New feature.*feature` ),
87- regexp .MustCompile (`#29.*Fixed bad bug.*hubot:bug-fix` ),
88- regexp .MustCompile (`#28.*Improve documentation.*docs` ),
89- }
90-
91- for i , r := range res {
92- if ! r .MatchString (lines [i ]) {
93- t .Errorf ("%s did not match %s" , lines [i ], r )
94- }
95- }
81+ Showing 3 of 3 open pull requests in OWNER/REPO
82+
83+ #32 New feature feature
84+ #29 Fixed bad bug hubot:bug-fix
85+ #28 Improve documentation docs
86+ ` ), output .String ())
87+ assert .Equal (t , `` , output .Stderr ())
9688}
9789
9890func TestPRList_nontty (t * testing.T ) {
@@ -130,8 +122,8 @@ func TestPRList_filtering(t *testing.T) {
130122 t .Fatal (err )
131123 }
132124
133- eq (t , output .String (), "" )
134- eq (t , output .Stderr (), `
125+ eq (t , output .Stderr (), "" )
126+ eq (t , output .String (), `
135127No pull requests match your search in OWNER/REPO
136128
137129` )
@@ -150,19 +142,12 @@ func TestPRList_filteringRemoveDuplicate(t *testing.T) {
150142 t .Fatal (err )
151143 }
152144
153- lines := strings .Split (output .String (), "\n " )
154-
155- res := []* regexp.Regexp {
156- regexp .MustCompile (`#32.*New feature.*feature` ),
157- regexp .MustCompile (`#29.*Fixed bad bug.*hubot:bug-fix` ),
158- regexp .MustCompile (`#28.*Improve documentation.*docs` ),
159- }
160-
161- for i , r := range res {
162- if ! r .MatchString (lines [i ]) {
163- t .Errorf ("%s did not match %s" , lines [i ], r )
164- }
145+ out := output .String ()
146+ idx := strings .Index (out , "New feature" )
147+ if idx < 0 {
148+ t .Fatalf ("text %q not found in %q" , "New feature" , out )
165149 }
150+ assert .Equal (t , idx , strings .LastIndex (out , "New feature" ))
166151}
167152
168153func TestPRList_filteringClosed (t * testing.T ) {
0 commit comments