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

Function runCommand

pkg/cmd/issue/view/view_test.go:65–101  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

63}
64
65func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
66 ios, _, stdout, stderr := iostreams.Test()
67 ios.SetStdoutTTY(isTTY)
68 ios.SetStdinTTY(isTTY)
69 ios.SetStderrTTY(isTTY)
70
71 factory := &cmdutil.Factory{
72 IOStreams: ios,
73 HttpClient: func() (*http.Client, error) {
74 return &http.Client{Transport: rt}, nil
75 },
76 Config: func() (gh.Config, error) {
77 return config.NewBlankConfig(), nil
78 },
79 BaseRepo: func() (ghrepo.Interface, error) {
80 return ghrepo.New("OWNER", "REPO"), nil
81 },
82 }
83
84 cmd := NewCmdView(factory, nil)
85
86 argv, err := shlex.Split(cli)
87 if err != nil {
88 return nil, err
89 }
90 cmd.SetArgs(argv)
91
92 cmd.SetIn(&bytes.Buffer{})
93 cmd.SetOut(io.Discard)
94 cmd.SetErr(io.Discard)
95
96 _, err = cmd.ExecuteC()
97 return &test.CmdOut{
98 OutBuf: stdout,
99 ErrBuf: stderr,
100 }, err
101}
102
103func TestIssueView_web(t *testing.T) {
104 ios, _, stdout, stderr := iostreams.Test()

Calls 7

TestFunction · 0.92
NewBlankConfigFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
NewCmdViewFunction · 0.70

Tested by

no test coverage detected