MCPcopy
hub / github.com/cli/cli / TestPRList_web

Function TestPRList_web

pkg/cmd/pr/list/list_test.go:292–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

290}
291
292func TestPRList_web(t *testing.T) {
293 tests := []struct {
294 name string
295 cli string
296 expectedBrowserURL string
297 }{
298 {
299 name: "filters",
300 cli: "-a peter -l bug -l docs -L 10 -s merged -B trunk",
301 expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=assignee%3Apeter+base%3Atrunk+is%3Amerged+label%3Abug+label%3Adocs+type%3Apr",
302 },
303 {
304 name: "draft",
305 cli: "--draft=true",
306 expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=draft%3Atrue+state%3Aopen+type%3Apr",
307 },
308 {
309 name: "non-draft",
310 cli: "--draft=0",
311 expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=draft%3Afalse+state%3Aopen+type%3Apr",
312 },
313 }
314
315 for _, test := range tests {
316 t.Run(test.name, func(t *testing.T) {
317 http := initFakeHTTP()
318 defer http.Verify(t)
319
320 _, cmdTeardown := run.Stub()
321 defer cmdTeardown(t)
322
323 output, err := runCommand(http, nil, true, "--web "+test.cli)
324 if err != nil {
325 t.Errorf("error running command `pr list` with `--web` flag: %v", err)
326 }
327
328 assert.Equal(t, "", output.String())
329 assert.Equal(t, "Opening https://github.com/OWNER/REPO/pulls in your browser.\n", output.Stderr())
330 assert.Equal(t, test.expectedBrowserURL, output.BrowsedURL)
331 })
332 }
333}
334
335func TestPRList_withProjectItems(t *testing.T) {
336 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 9

StubFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
initFakeHTTPFunction · 0.70
runCommandFunction · 0.70
RunMethod · 0.65
VerifyMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected