MCPcopy
hub / github.com/cli/cli / Test_viewRun_json

Function Test_viewRun_json

pkg/cmd/repo/view/view_test.go:709–740  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

707}
708
709func 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
742type testExporter struct {
743 fields []string

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
StubRepoInfoResponseMethod · 0.95
TestFunction · 0.92
NewFunction · 0.92
StubFunction · 0.92
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
viewRunFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected