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

Function TestIssueView_nontty_Preview

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

Source from the content-addressed store, hash-verified

155}
156
157func TestIssueView_nontty_Preview(t *testing.T) {
158 tests := map[string]struct {
159 httpStubs func(*httpmock.Registry)
160 expectedOutputs []string
161 }{
162 "Open issue without metadata": {
163 httpStubs: func(r *httpmock.Registry) {
164 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_preview.json"))
165 mockEmptyV2ProjectItems(t, r)
166 },
167 expectedOutputs: []string{
168 `title:\tix of coins`,
169 `state:\tOPEN`,
170 `comments:\t9`,
171 `author:\tmarseilles`,
172 `assignees:`,
173 `number:\t123\n`,
174 `\*\*bold story\*\*`,
175 },
176 },
177 "Open issue with metadata": {
178 httpStubs: func(r *httpmock.Registry) {
179 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithMetadata.json"))
180 mockV2ProjectItems(t, r)
181 },
182 expectedOutputs: []string{
183 `title:\tix of coins`,
184 `assignees:\tmarseilles, monaco`,
185 `author:\tmarseilles`,
186 `state:\tOPEN`,
187 `comments:\t9`,
188 `labels:\tClosed: Duplicate, Closed: Won't Fix, help wanted, Status: In Progress, Type: Bug`,
189 `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`,
190 `milestone:\tuluru\n`,
191 `number:\t123\n`,
192 `\*\*bold story\*\*`,
193 },
194 },
195 "Open issue with empty body": {
196 httpStubs: func(r *httpmock.Registry) {
197 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithEmptyBody.json"))
198 mockEmptyV2ProjectItems(t, r)
199 },
200 expectedOutputs: []string{
201 `title:\tix of coins`,
202 `state:\tOPEN`,
203 `author:\tmarseilles`,
204 `labels:\ttarot`,
205 `number:\t123\n`,
206 },
207 },
208 "Closed issue": {
209 httpStubs: func(r *httpmock.Registry) {
210 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewClosedState.json"))
211 mockEmptyV2ProjectItems(t, r)
212 },
213 expectedOutputs: []string{
214 `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
StringMethod · 0.65

Tested by

no test coverage detected