MCPcopy
hub / github.com/cli/cli / TestIssueView_nontty_Preview

Function TestIssueView_nontty_Preview

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

Source from the content-addressed store, hash-verified

143}
144
145func TestIssueView_nontty_Preview(t *testing.T) {
146 tests := map[string]struct {
147 httpStubs func(*httpmock.Registry)
148 expectedOutputs []string
149 }{
150 "Open issue without metadata": {
151 httpStubs: func(r *httpmock.Registry) {
152 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_preview.json"))
153 mockEmptyV2ProjectItems(t, r)
154 },
155 expectedOutputs: []string{
156 `title:\tix of coins`,
157 `state:\tOPEN`,
158 `comments:\t9`,
159 `author:\tmarseilles`,
160 `assignees:`,
161 `number:\t123\n`,
162 `\*\*bold story\*\*`,
163 },
164 },
165 "Open issue with metadata": {
166 httpStubs: func(r *httpmock.Registry) {
167 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithMetadata.json"))
168 mockV2ProjectItems(t, r)
169 },
170 expectedOutputs: []string{
171 `title:\tix of coins`,
172 `assignees:\tmarseilles, monaco`,
173 `author:\tmarseilles`,
174 `state:\tOPEN`,
175 `comments:\t9`,
176 `labels:\tClosed: Duplicate, Closed: Won't Fix, help wanted, Status: In Progress, Type: Bug`,
177 `projects:\tv2 Project 1 \(No Status\), v2 Project 2 \(Done\), Project 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), Project 4 \(Awaiting triage\)\n`,
178 `milestone:\tuluru\n`,
179 `number:\t123\n`,
180 `\*\*bold story\*\*`,
181 },
182 },
183 "Open issue with empty body": {
184 httpStubs: func(r *httpmock.Registry) {
185 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithEmptyBody.json"))
186 mockEmptyV2ProjectItems(t, r)
187 },
188 expectedOutputs: []string{
189 `title:\tix of coins`,
190 `state:\tOPEN`,
191 `author:\tmarseilles`,
192 `labels:\ttarot`,
193 `number:\t123\n`,
194 },
195 },
196 "Closed issue": {
197 httpStubs: func(r *httpmock.Registry) {
198 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewClosedState.json"))
199 mockEmptyV2ProjectItems(t, r)
200 },
201 expectedOutputs: []string{
202 `title:\tix of coins`,

Callers

nothing calls this directly

Calls 13

VerifyMethod · 0.95
GraphQLFunction · 0.92
FileResponseFunction · 0.92
ExpectLinesFunction · 0.92
mockEmptyV2ProjectItemsFunction · 0.85
mockV2ProjectItemsFunction · 0.85
EqualMethod · 0.80
StderrMethod · 0.80
runCommandFunction · 0.70
RunMethod · 0.65
ErrorfMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected