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

Function runCommand

pkg/cmd/issue/reopen/reopen_test.go:27–63  ·  view source on GitHub ↗
(rt http.RoundTripper, isTTY bool, cli string)

Source from the content-addressed store, hash-verified

25}
26
27func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) {
28 ios, _, stdout, stderr := iostreams.Test()
29 ios.SetStdoutTTY(isTTY)
30 ios.SetStdinTTY(isTTY)
31 ios.SetStderrTTY(isTTY)
32
33 factory := &cmdutil.Factory{
34 IOStreams: ios,
35 HttpClient: func() (*http.Client, error) {
36 return &http.Client{Transport: rt}, nil
37 },
38 Config: func() (gh.Config, error) {
39 return config.NewBlankConfig(), nil
40 },
41 BaseRepo: func() (ghrepo.Interface, error) {
42 return ghrepo.New("OWNER", "REPO"), nil
43 },
44 }
45
46 cmd := NewCmdReopen(factory, nil)
47
48 argv, err := shlex.Split(cli)
49 if err != nil {
50 return nil, err
51 }
52 cmd.SetArgs(argv)
53
54 cmd.SetIn(&bytes.Buffer{})
55 cmd.SetOut(io.Discard)
56 cmd.SetErr(io.Discard)
57
58 _, err = cmd.ExecuteC()
59 return &test.CmdOut{
60 OutBuf: stdout,
61 ErrBuf: stderr,
62 }, err
63}
64
65func TestIssueReopen(t *testing.T) {
66 http := &httpmock.Registry{}

Callers 4

TestIssueReopenFunction · 0.70

Calls 7

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

Tested by

no test coverage detected