|
4 | 4 | "bytes" |
5 | 5 | "io/ioutil" |
6 | 6 | "net/http" |
7 | | - "os/exec" |
8 | 7 | "strings" |
9 | 8 | "testing" |
10 | 9 |
|
@@ -72,7 +71,7 @@ func TestPRList(t *testing.T) { |
72 | 71 | assert.Equal(t, heredoc.Doc(` |
73 | 72 |
|
74 | 73 | Showing 3 of 3 open pull requests in OWNER/REPO |
75 | | - |
| 74 | +
|
76 | 75 | #32 New feature feature |
77 | 76 | #29 Fixed bad bug hubot:bug-fix |
78 | 77 | #28 Improve documentation docs |
@@ -199,27 +198,19 @@ func TestPRList_web(t *testing.T) { |
199 | 198 | http := initFakeHTTP() |
200 | 199 | defer http.Verify(t) |
201 | 200 |
|
202 | | - var seenCmd *exec.Cmd |
203 | | - //nolint:staticcheck // SA1019 TODO: rewrite to use run.Stub |
204 | | - restoreCmd := run.SetPrepareCmd(func(cmd *exec.Cmd) run.Runnable { |
205 | | - seenCmd = cmd |
206 | | - return &test.OutputStub{} |
| 201 | + cs, cmdTeardown := run.Stub() |
| 202 | + defer cmdTeardown(t) |
| 203 | + |
| 204 | + cs.Register(`https://github\.com`, 0, "", func(args []string) { |
| 205 | + url := strings.ReplaceAll(args[len(args)-1], "^", "") |
| 206 | + assert.Equal(t, "https://github.com/OWNER/REPO/pulls?q=is%3Apr+is%3Amerged+assignee%3Apeter+label%3Abug+label%3Adocs+base%3Atrunk", url) |
207 | 207 | }) |
208 | | - defer restoreCmd() |
209 | 208 |
|
210 | 209 | output, err := runCommand(http, true, "--web -a peter -l bug -l docs -L 10 -s merged -B trunk") |
211 | 210 | if err != nil { |
212 | 211 | t.Errorf("error running command `pr list` with `--web` flag: %v", err) |
213 | 212 | } |
214 | 213 |
|
215 | | - expectedURL := "https://github.com/OWNER/REPO/pulls?q=is%3Apr+is%3Amerged+assignee%3Apeter+label%3Abug+label%3Adocs+base%3Atrunk" |
216 | | - |
217 | 214 | assert.Equal(t, "", output.String()) |
218 | 215 | assert.Equal(t, "Opening github.com/OWNER/REPO/pulls in your browser.\n", output.Stderr()) |
219 | | - |
220 | | - if seenCmd == nil { |
221 | | - t.Fatal("expected a command to run") |
222 | | - } |
223 | | - url := seenCmd.Args[len(seenCmd.Args)-1] |
224 | | - assert.Equal(t, url, expectedURL) |
225 | 216 | } |
0 commit comments