(t *testing.T)
| 707 | } |
| 708 | |
| 709 | func Test_viewRun_json(t *testing.T) { |
| 710 | io, _, stdout, stderr := iostreams.Test() |
| 711 | io.SetStdoutTTY(false) |
| 712 | |
| 713 | reg := &httpmock.Registry{} |
| 714 | defer reg.Verify(t) |
| 715 | reg.StubRepoInfoResponse("OWNER", "REPO", "main") |
| 716 | |
| 717 | opts := &ViewOptions{ |
| 718 | IO: io, |
| 719 | HttpClient: func() (*http.Client, error) { |
| 720 | return &http.Client{Transport: reg}, nil |
| 721 | }, |
| 722 | BaseRepo: func() (ghrepo.Interface, error) { |
| 723 | return ghrepo.New("OWNER", "REPO"), nil |
| 724 | }, |
| 725 | Exporter: &testExporter{ |
| 726 | fields: []string{"name", "defaultBranchRef"}, |
| 727 | }, |
| 728 | } |
| 729 | |
| 730 | _, teardown := run.Stub() |
| 731 | defer teardown(t) |
| 732 | |
| 733 | err := viewRun(opts) |
| 734 | assert.NoError(t, err) |
| 735 | assert.Equal(t, heredoc.Doc(` |
| 736 | name: REPO |
| 737 | defaultBranchRef: main |
| 738 | `), stdout.String()) |
| 739 | assert.Equal(t, "", stderr.String()) |
| 740 | } |
| 741 | |
| 742 | type testExporter struct { |
| 743 | fields []string |
nothing calls this directly
no test coverage detected