(rt http.RoundTripper, isTTY bool, cli string)
| 74 | } |
| 75 | |
| 76 | func runCommand(rt http.RoundTripper, isTTY bool, cli string) (*test.CmdOut, error) { |
| 77 | ios, _, stdout, stderr := iostreams.Test() |
| 78 | ios.SetStdoutTTY(isTTY) |
| 79 | ios.SetStdinTTY(isTTY) |
| 80 | ios.SetStderrTTY(isTTY) |
| 81 | |
| 82 | factory := &cmdutil.Factory{ |
| 83 | IOStreams: ios, |
| 84 | HttpClient: func() (*http.Client, error) { |
| 85 | return &http.Client{Transport: rt}, nil |
| 86 | }, |
| 87 | Config: func() (gh.Config, error) { |
| 88 | return config.NewBlankConfig(), nil |
| 89 | }, |
| 90 | BaseRepo: func() (ghrepo.Interface, error) { |
| 91 | return ghrepo.New("OWNER", "REPO"), nil |
| 92 | }, |
| 93 | } |
| 94 | |
| 95 | fakeNow := func() time.Time { |
| 96 | return time.Date(2022, time.August, 25, 23, 50, 0, 0, time.UTC) |
| 97 | } |
| 98 | |
| 99 | cmd := NewCmdList(factory, func(opts *ListOptions) error { |
| 100 | opts.Now = fakeNow |
| 101 | return listRun(opts) |
| 102 | }) |
| 103 | |
| 104 | argv, err := shlex.Split(cli) |
| 105 | if err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | cmd.SetArgs(argv) |
| 109 | |
| 110 | cmd.SetIn(&bytes.Buffer{}) |
| 111 | cmd.SetOut(io.Discard) |
| 112 | cmd.SetErr(io.Discard) |
| 113 | |
| 114 | _, err = cmd.ExecuteC() |
| 115 | return &test.CmdOut{ |
| 116 | OutBuf: stdout, |
| 117 | ErrBuf: stderr, |
| 118 | }, err |
| 119 | } |
| 120 | |
| 121 | func TestIssueList_nontty(t *testing.T) { |
| 122 | http := &httpmock.Registry{} |
no test coverage detected