(t *testing.T)
| 369 | } |
| 370 | |
| 371 | func Test_ViewRun_NonMarkdownReadme(t *testing.T) { |
| 372 | tests := []struct { |
| 373 | name string |
| 374 | stdoutTTY bool |
| 375 | wantOut string |
| 376 | }{ |
| 377 | { |
| 378 | name: "tty", |
| 379 | wantOut: heredoc.Doc(` |
| 380 | OWNER/REPO |
| 381 | social distancing |
| 382 | |
| 383 | # truly cool readme check it out |
| 384 | |
| 385 | View this repository on GitHub: https://github.com/OWNER/REPO |
| 386 | `), |
| 387 | stdoutTTY: true, |
| 388 | }, |
| 389 | { |
| 390 | name: "nontty", |
| 391 | wantOut: heredoc.Doc(` |
| 392 | name: OWNER/REPO |
| 393 | description: social distancing |
| 394 | -- |
| 395 | # truly cool readme check it out |
| 396 | `), |
| 397 | }, |
| 398 | } |
| 399 | |
| 400 | for _, tt := range tests { |
| 401 | reg := &httpmock.Registry{} |
| 402 | reg.Register( |
| 403 | httpmock.GraphQL(`query RepositoryInfo\b`), |
| 404 | httpmock.StringResponse(` |
| 405 | { "data": { |
| 406 | "repository": { |
| 407 | "description": "social distancing" |
| 408 | } } }`)) |
| 409 | reg.Register( |
| 410 | httpmock.REST("GET", "repos/OWNER/REPO/readme"), |
| 411 | httpmock.StringResponse(` |
| 412 | { "name": "readme.org", |
| 413 | "content": "IyB0cnVseSBjb29sIHJlYWRtZSBjaGVjayBpdCBvdXQ="}`)) |
| 414 | |
| 415 | opts := &ViewOptions{ |
| 416 | HttpClient: func() (*http.Client, error) { |
| 417 | return &http.Client{Transport: reg}, nil |
| 418 | }, |
| 419 | BaseRepo: func() (ghrepo.Interface, error) { |
| 420 | return ghrepo.New("OWNER", "REPO"), nil |
| 421 | }, |
| 422 | } |
| 423 | |
| 424 | io, _, stdout, stderr := iostreams.Test() |
| 425 | |
| 426 | opts.IO = io |
| 427 | |
| 428 | t.Run(tt.name, func(t *testing.T) { |
nothing calls this directly
no test coverage detected