(t *testing.T)
| 505 | } |
| 506 | |
| 507 | func Test_ViewRun_NoDescription(t *testing.T) { |
| 508 | tests := []struct { |
| 509 | name string |
| 510 | stdoutTTY bool |
| 511 | wantOut string |
| 512 | }{ |
| 513 | { |
| 514 | name: "tty", |
| 515 | wantOut: heredoc.Doc(` |
| 516 | OWNER/REPO |
| 517 | No description provided |
| 518 | |
| 519 | # truly cool readme check it out |
| 520 | |
| 521 | View this repository on GitHub: https://github.com/OWNER/REPO |
| 522 | `), |
| 523 | stdoutTTY: true, |
| 524 | }, |
| 525 | { |
| 526 | name: "nontty", |
| 527 | wantOut: heredoc.Doc(` |
| 528 | name: OWNER/REPO |
| 529 | description: |
| 530 | -- |
| 531 | # truly cool readme check it out |
| 532 | `), |
| 533 | }, |
| 534 | } |
| 535 | |
| 536 | for _, tt := range tests { |
| 537 | reg := &httpmock.Registry{} |
| 538 | reg.Register( |
| 539 | httpmock.GraphQL(`query RepositoryInfo\b`), |
| 540 | httpmock.StringResponse(` |
| 541 | { "data": { |
| 542 | "repository": { |
| 543 | "description": "" |
| 544 | } } }`)) |
| 545 | reg.Register( |
| 546 | httpmock.REST("GET", "repos/OWNER/REPO/readme"), |
| 547 | httpmock.StringResponse(` |
| 548 | { "name": "readme.org", |
| 549 | "content": "IyB0cnVseSBjb29sIHJlYWRtZSBjaGVjayBpdCBvdXQ="}`)) |
| 550 | |
| 551 | opts := &ViewOptions{ |
| 552 | HttpClient: func() (*http.Client, error) { |
| 553 | return &http.Client{Transport: reg}, nil |
| 554 | }, |
| 555 | BaseRepo: func() (ghrepo.Interface, error) { |
| 556 | return ghrepo.New("OWNER", "REPO"), nil |
| 557 | }, |
| 558 | } |
| 559 | |
| 560 | io, _, stdout, stderr := iostreams.Test() |
| 561 | |
| 562 | opts.IO = io |
| 563 | |
| 564 | t.Run(tt.name, func(t *testing.T) { |
nothing calls this directly
no test coverage detected