MCPcopy
hub / github.com/cli/cli / runCommand

Function runCommand

pkg/cmd/issue/list/list_test.go:76–119  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

74}
75
76func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
77 ios, _, stdout, stderr := iostreams.Test()
78 ios.SetStdoutTTY(isTTY)
79 ios.SetStdinTTY(isTTY)
80 ios.SetStderrTTY(isTTY)
81
82 factory := &cmdutil.Factory{
83 IOStreams: ios,
84 HttpClient: func() (*http.Client, error) {
85 return &http.Client{Transport: rt}, nil
86 },
87 Config: func() (gh.Config, error) {
88 return config.NewBlankConfig(), nil
89 },
90 BaseRepo: func() (ghrepo.Interface, error) {
91 return ghrepo.New("OWNER", "REPO"), nil
92 },
93 }
94
95 fakeNow := func() time.Time {
96 return time.Date(2022, time.August, 25, 23, 50, 0, 0, time.UTC)
97 }
98
99 cmd := NewCmdList(factory, func(opts *ListOptions) error {
100 opts.Now = fakeNow
101 return listRun(opts)
102 })
103
104 argv, err := shlex.Split(cli)
105 if err != nil {
106 return nil, err
107 }
108 cmd.SetArgs(argv)
109
110 cmd.SetIn(&bytes.Buffer{})
111 cmd.SetOut(io.Discard)
112 cmd.SetErr(io.Discard)
113
114 _, err = cmd.ExecuteC()
115 return &test.CmdOut{
116 OutBuf: stdout,
117 ErrBuf: stderr,
118 }, err
119}
120
121func TestIssueList_nontty(t *testing.T) {
122 http := &httpmock.Registry{}

Callers 6

TestIssueList_nonttyFunction · 0.70
TestIssueList_ttyFunction · 0.70

Calls 8

TestFunction · 0.92
NewBlankConfigFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdListFunction · 0.70
listRunFunction · 0.70

Tested by

no test coverage detected