MCPcopy Create free account
hub / github.com/cli/cli / TestIssueView_web

Function TestIssueView_web

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

Source from the content-addressed store, hash-verified

113}
114
115func TestIssueView_web(t *testing.T) {
116 ios, _, stdout, stderr := iostreams.Test()
117 ios.SetStdoutTTY(true)
118 ios.SetStderrTTY(true)
119 browser := &browser.Stub{}
120
121 reg := &httpmock.Registry{}
122 defer reg.Verify(t)
123
124 reg.Register(
125 httpmock.GraphQL(`query IssueByNumber\b`),
126 httpmock.StringResponse(`
127 { "data": { "repository": { "hasIssuesEnabled": true, "issue": {
128 "number": 123,
129 "url": "https://github.com/OWNER/REPO/issues/123"
130 } } } }
131 `))
132
133 _, cmdTeardown := run.Stub()
134 defer cmdTeardown(t)
135
136 err := viewRun(&ViewOptions{
137 IO: ios,
138 Browser: browser,
139 HttpClient: func() (*http.Client, error) {
140 return &http.Client{Transport: reg}, nil
141 },
142 BaseRepo: func() (ghrepo.Interface, error) {
143 return ghrepo.New("OWNER", "REPO"), nil
144 },
145 WebMode: true,
146 IssueNumber: 123,
147 })
148 if err != nil {
149 t.Errorf("error running command `issue view`: %v", err)
150 }
151
152 assert.Equal(t, "", stdout.String())
153 assert.Equal(t, "Opening https://github.com/OWNER/REPO/issues/123 in your browser.\n", stderr.String())
154 browser.Verify(t, "https://github.com/OWNER/REPO/issues/123")
155}
156
157func TestIssueView_nontty_Preview(t *testing.T) {
158 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