MCPcopy Create free account
hub / github.com/cli/cli / runCommand

Function runCommand

pkg/cmd/pr/view/view_test.go:175–208  ·  view source on GitHub ↗
(rt http.RoundTripper, branch string, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

173}
174
175func runCommand(rt http.RoundTripper, branch string, isTTY bool, cli string) (*test.CmdOut, error) {
176 ios, _, stdout, stderr := iostreams.Test()
177 ios.SetStdoutTTY(isTTY)
178 ios.SetStdinTTY(isTTY)
179 ios.SetStderrTTY(isTTY)
180
181 browser := &browser.Stub{}
182 factory := &cmdutil.Factory{
183 IOStreams: ios,
184 Browser: browser,
185 HttpClient: func() (*http.Client, error) {
186 return &http.Client{Transport: rt}, nil
187 },
188 }
189
190 cmd := NewCmdView(factory, nil)
191
192 argv, err := shlex.Split(cli)
193 if err != nil {
194 return nil, err
195 }
196 cmd.SetArgs(argv)
197
198 cmd.SetIn(&bytes.Buffer{})
199 cmd.SetOut(io.Discard)
200 cmd.SetErr(io.Discard)
201
202 _, err = cmd.ExecuteC()
203 return &test.CmdOut{
204 OutBuf: stdout,
205 ErrBuf: stderr,
206 BrowsedURL: browser.BrowsedURL(),
207 }, err
208}
209
210// hack for compatibility with old JSON fixture files
211func prFromFixtures(fixtures map[string]string) (*api.PullRequest, error) {

Callers 6

TestPRView_PreviewFunction · 0.70
TestPRView_tty_CommentsFunction · 0.70

Calls 6

BrowsedURLMethod · 0.95
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdViewFunction · 0.70

Tested by

no test coverage detected