|
5 | 5 | "encoding/json" |
6 | 6 | "io/ioutil" |
7 | 7 | "net/http" |
8 | | - "os/exec" |
9 | 8 | "regexp" |
| 9 | + "strings" |
10 | 10 | "testing" |
11 | 11 |
|
12 | 12 | "github.com/MakeNowJust/heredoc" |
@@ -235,29 +235,21 @@ func TestIssueList_web(t *testing.T) { |
235 | 235 | http := &httpmock.Registry{} |
236 | 236 | defer http.Verify(t) |
237 | 237 |
|
238 | | - var seenCmd *exec.Cmd |
239 | | - //nolint:staticcheck // SA1019 TODO: rewrite to use run.Stub |
240 | | - restoreCmd := run.SetPrepareCmd(func(cmd *exec.Cmd) run.Runnable { |
241 | | - seenCmd = cmd |
242 | | - return &test.OutputStub{} |
| 238 | + cs, cmdTeardown := run.Stub() |
| 239 | + defer cmdTeardown(t) |
| 240 | + |
| 241 | + cs.Register(`https://github\.com`, 0, "", func(args []string) { |
| 242 | + url := strings.ReplaceAll(args[len(args)-1], "^", "") |
| 243 | + assert.Equal(t, "https://github.com/OWNER/REPO/issues?q=is%3Aissue+assignee%3Apeter+label%3Abug+label%3Adocs+author%3Ajohn+mentions%3Afrank+milestone%3Av1.1", url) |
243 | 244 | }) |
244 | | - defer restoreCmd() |
245 | 245 |
|
246 | 246 | output, err := runCommand(http, true, "--web -a peter -A john -l bug -l docs -L 10 -s all --mention frank --milestone v1.1") |
247 | 247 | if err != nil { |
248 | 248 | t.Errorf("error running command `issue list` with `--web` flag: %v", err) |
249 | 249 | } |
250 | 250 |
|
251 | | - expectedURL := "https://github.com/OWNER/REPO/issues?q=is%3Aissue+assignee%3Apeter+label%3Abug+label%3Adocs+author%3Ajohn+mentions%3Afrank+milestone%3Av1.1" |
252 | | - |
253 | 251 | assert.Equal(t, "", output.String()) |
254 | 252 | assert.Equal(t, "Opening github.com/OWNER/REPO/issues in your browser.\n", output.Stderr()) |
255 | | - |
256 | | - if seenCmd == nil { |
257 | | - t.Fatal("expected a command to run") |
258 | | - } |
259 | | - url := seenCmd.Args[len(seenCmd.Args)-1] |
260 | | - assert.Equal(t, expectedURL, url) |
261 | 253 | } |
262 | 254 |
|
263 | 255 | func TestIssueList_milestoneNotFound(t *testing.T) { |
|
0 commit comments