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

Function runCommand

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

Source from the content-addressed store, hash-verified

346}
347
348func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
349 ios, _, stdout, stderr := iostreams.Test()
350 ios.SetStdoutTTY(isTTY)
351 ios.SetStdinTTY(isTTY)
352 ios.SetStderrTTY(isTTY)
353
354 factory := &cmdutil.Factory{
355 IOStreams: ios,
356 HttpClient: func() (*http.Client, error) {
357 return &http.Client{Transport: rt}, nil
358 },
359 Config: func() (gh.Config, error) {
360 return config.NewBlankConfig(), nil
361 },
362 }
363
364 cmd := NewCmdList(factory, nil)
365
366 argv, err := shlex.Split(cli)
367 if err != nil {
368 return nil, err
369 }
370 cmd.SetArgs(argv)
371
372 cmd.SetIn(&bytes.Buffer{})
373 cmd.SetOut(io.Discard)
374 cmd.SetErr(io.Discard)
375
376 _, err = cmd.ExecuteC()
377 return &test.CmdOut{
378 OutBuf: stdout,
379 ErrBuf: stderr,
380 }, err
381}
382
383func TestRepoList_nontty(t *testing.T) {
384 ios, _, stdout, stderr := iostreams.Test()

Callers 1

TestRepoList_filteringFunction · 0.70

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…