MCPcopy Index your code
hub / github.com/cli/cli / TestIssueView_nontty_Comments

Function TestIssueView_nontty_Comments

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

Source from the content-addressed store, hash-verified

458}
459
460func TestIssueView_nontty_Comments(t *testing.T) {
461 tests := map[string]struct {
462 cli string
463 httpStubs func(*httpmock.Registry)
464 expectedOutputs []string
465 wantsErr bool
466 }{
467 "without comments flag": {
468 cli: "123",
469 httpStubs: func(r *httpmock.Registry) {
470 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
471 mockEmptyV2ProjectItems(t, r)
472 },
473 expectedOutputs: []string{
474 `title:\tsome title`,
475 `state:\tOPEN`,
476 `author:\tmarseilles`,
477 `comments:\t6`,
478 `number:\t123`,
479 `some body`,
480 },
481 },
482 "with comments flag": {
483 cli: "123 --comments",
484 httpStubs: func(r *httpmock.Registry) {
485 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
486 r.Register(httpmock.GraphQL(`query CommentsForIssue\b`), httpmock.FileResponse("./fixtures/issueView_previewFullComments.json"))
487 mockEmptyV2ProjectItems(t, r)
488 },
489 expectedOutputs: []string{
490 `author:\tmonalisa`,
491 `association:\t`,
492 `edited:\ttrue`,
493 `Comment 1`,
494 `author:\tjohnnytest`,
495 `association:\tcontributor`,
496 `edited:\tfalse`,
497 `Comment 2`,
498 `author:\telvisp`,
499 `association:\tmember`,
500 `edited:\tfalse`,
501 `Comment 3`,
502 `author:\tloislane`,
503 `association:\towner`,
504 `edited:\tfalse`,
505 `Comment 4`,
506 `author:\tmarseilles`,
507 `association:\tcollaborator`,
508 `edited:\tfalse`,
509 `Comment 5`,
510 },
511 },
512 "with invalid comments flag": {
513 cli: "123 --comments 3",
514 wantsErr: true,
515 },
516 }
517 for name, tc := range tests {

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected