MCPcopy
hub / github.com/cli/cli / TestIssueView_web

Function TestIssueView_web

pkg/cmd/issue/view/view_test.go:103–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestIssueView_web(t *testing.T) {
104 ios, _, stdout, stderr := iostreams.Test()
105 ios.SetStdoutTTY(true)
106 ios.SetStderrTTY(true)
107 browser := &browser.Stub{}
108
109 reg := &httpmock.Registry{}
110 defer reg.Verify(t)
111
112 reg.Register(
113 httpmock.GraphQL(`query IssueByNumber\b`),
114 httpmock.StringResponse(`
115 { "data": { "repository": { "hasIssuesEnabled": true, "issue": {
116 "number": 123,
117 "url": "https://github.com/OWNER/REPO/issues/123"
118 } } } }
119 `))
120
121 _, cmdTeardown := run.Stub()
122 defer cmdTeardown(t)
123
124 err := viewRun(&ViewOptions{
125 IO: ios,
126 Browser: browser,
127 HttpClient: func() (*http.Client, error) {
128 return &http.Client{Transport: reg}, nil
129 },
130 BaseRepo: func() (ghrepo.Interface, error) {
131 return ghrepo.New("OWNER", "REPO"), nil
132 },
133 WebMode: true,
134 IssueNumber: 123,
135 })
136 if err != nil {
137 t.Errorf("error running command `issue view`: %v", err)
138 }
139
140 assert.Equal(t, "", stdout.String())
141 assert.Equal(t, "Opening https://github.com/OWNER/REPO/issues/123 in your browser.\n", stderr.String())
142 browser.Verify(t, "https://github.com/OWNER/REPO/issues/123")
143}
144
145func TestIssueView_nontty_Preview(t *testing.T) {
146 tests := map[string]struct {

Callers

nothing calls this directly

Calls 14

VerifyMethod · 0.95
RegisterMethod · 0.95
VerifyMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
StubFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
viewRunFunction · 0.70

Tested by

no test coverage detected