MCPcopy
hub / github.com/cli/cli / TestIssueView_tty_Preview

Function TestIssueView_tty_Preview

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

Source from the content-addressed store, hash-verified

231}
232
233func TestIssueView_tty_Preview(t *testing.T) {
234 tests := map[string]struct {
235 httpStubs func(*httpmock.Registry)
236 expectedOutputs []string
237 }{
238 "Open issue without metadata": {
239 httpStubs: func(r *httpmock.Registry) {
240 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_preview.json"))
241 mockEmptyV2ProjectItems(t, r)
242 },
243 expectedOutputs: []string{
244 `ix of coins OWNER/REPO#123`,
245 `Open.*marseilles opened about 9 years ago.*9 comments`,
246 `bold story`,
247 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
248 },
249 },
250 "Open issue with metadata": {
251 httpStubs: func(r *httpmock.Registry) {
252 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithMetadata.json"))
253 mockV2ProjectItems(t, r)
254 },
255 expectedOutputs: []string{
256 `ix of coins OWNER/REPO#123`,
257 `Open.*marseilles opened about 9 years ago.*9 comments`,
258 `8 \x{1f615} • 7 \x{1f440} • 6 \x{2764}\x{fe0f} • 5 \x{1f389} • 4 \x{1f604} • 3 \x{1f680} • 2 \x{1f44e} • 1 \x{1f44d}`,
259 `Assignees:.*marseilles, monaco\n`,
260 `Labels:.*Closed: Duplicate, Closed: Won't Fix, help wanted, Status: In Progress, Type: Bug\n`,
261 `Projects:.*v2 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`,
262 `Milestone:.*uluru\n`,
263 `bold story`,
264 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
265 },
266 },
267 "Open issue with empty body": {
268 httpStubs: func(r *httpmock.Registry) {
269 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewWithEmptyBody.json"))
270 mockEmptyV2ProjectItems(t, r)
271 },
272 expectedOutputs: []string{
273 `ix of coins OWNER/REPO#123`,
274 `Open.*marseilles opened about 9 years ago.*9 comments`,
275 `No description provided`,
276 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
277 },
278 },
279 "Closed issue": {
280 httpStubs: func(r *httpmock.Registry) {
281 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewClosedState.json"))
282 mockEmptyV2ProjectItems(t, r)
283 },
284 expectedOutputs: []string{
285 `ix of coins OWNER/REPO#123`,
286 `Closed.*marseilles opened about 9 years ago.*9 comments`,
287 `bold story`,
288 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
289 },
290 },

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
GraphQLFunction · 0.92
FileResponseFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
ExpectLinesFunction · 0.92
mockEmptyV2ProjectItemsFunction · 0.85
mockV2ProjectItemsFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected