(t *testing.T)
| 470 | } |
| 471 | |
| 472 | func 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 { |
nothing calls this directly
no test coverage detected