(rt http.RoundTripper, isTTY bool, cli string)
| 75 | } |
| 76 | |
| 77 | func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) { |
| 78 | ios, _, stdout, stderr := iostreams.Test() |
| 79 | ios.SetStdoutTTY(isTTY) |
| 80 | ios.SetStdinTTY(isTTY) |
| 81 | ios.SetStderrTTY(isTTY) |
| 82 | |
| 83 | factory := &cmdutil.Factory{ |
| 84 | IOStreams: ios, |
| 85 | HttpClient: func() (*http.Client, error) { |
| 86 | return &http.Client{Transport: rt}, nil |
| 87 | }, |
| 88 | Config: func() (gh.Config, error) { |
| 89 | return config.NewMockConfig(), nil |
| 90 | }, |
| 91 | BaseRepo: func() (ghrepo.Interface, error) { |
| 92 | return ghrepo.New("OWNER", "REPO"), nil |
| 93 | }, |
| 94 | } |
| 95 | |
| 96 | cmd := NewCmdView(factory, nil) |
| 97 | |
| 98 | argv, err := shlex.Split(cli) |
| 99 | if err != nil { |
| 100 | return nil, err |
| 101 | } |
| 102 | cmd.SetArgs(argv) |
| 103 | |
| 104 | cmd.SetIn(&bytes.Buffer{}) |
| 105 | cmd.SetOut(io.Discard) |
| 106 | cmd.SetErr(io.Discard) |
| 107 | |
| 108 | _, err = cmd.ExecuteC() |
| 109 | return &test.CmdOut{ |
| 110 | OutBuf: stdout, |
| 111 | ErrBuf: stderr, |
| 112 | }, err |
| 113 | } |
| 114 | |
| 115 | func TestIssueView_web(t *testing.T) { |
| 116 | ios, _, stdout, stderr := iostreams.Test() |
no test coverage detected