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

Function TestIssueView_nontty_Comments

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

Source from the content-addressed store, hash-verified

470}
471
472func TestIssueView_nontty_Comments(t *testing.T) {
473 tests := map[string]struct {
474 cli string
475 httpStubs func(*httpmock.Registry)
476 expectedOutputs []string
477 wantsErr bool
478 }{
479 "without comments flag": {
480 cli: "123",
481 httpStubs: func(r *httpmock.Registry) {
482 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
483 mockEmptyV2ProjectItems(t, r)
484 },
485 expectedOutputs: []string{
486 `title:\tsome title`,
487 `state:\tOPEN`,
488 `author:\tmarseilles`,
489 `comments:\t6`,
490 `number:\t123`,
491 `some body`,
492 },
493 },
494 "with comments flag": {
495 cli: "123 --comments",
496 httpStubs: func(r *httpmock.Registry) {
497 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
498 r.Register(httpmock.GraphQL(`query CommentsForIssue\b`), httpmock.FileResponse("./fixtures/issueView_previewFullComments.json"))
499 mockEmptyV2ProjectItems(t, r)
500 },
501 expectedOutputs: []string{
502 `author:\tmonalisa`,
503 `association:\t`,
504 `edited:\ttrue`,
505 `Comment 1`,
506 `author:\tjohnnytest`,
507 `association:\tcontributor`,
508 `edited:\tfalse`,
509 `Comment 2`,
510 `author:\telvisp`,
511 `association:\tmember`,
512 `edited:\tfalse`,
513 `Comment 3`,
514 `author:\tloislane`,
515 `association:\towner`,
516 `edited:\tfalse`,
517 `Comment 4`,
518 `author:\tmarseilles`,
519 `association:\tcollaborator`,
520 `edited:\tfalse`,
521 `Comment 5`,
522 },
523 },
524 "with invalid comments flag": {
525 cli: "123 --comments 3",
526 wantsErr: true,
527 },
528 }
529 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
StringMethod · 0.65
RegisterMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected