MCPcopy
hub / github.com/cli/cli / TestListRun

Function TestListRun

pkg/cmd/discussion/list/list_test.go:231–635  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

229}
230
231func TestListRun(t *testing.T) {
232 tests := []struct {
233 name string
234 opts ListOptions
235 tty bool
236 clientStub func(*testing.T, *client.DiscussionClientMock)
237 wantErr string
238 wantErrAs any
239 wantStdout string
240 wantStderr string
241 wantBrowse string
242 }{
243 {
244 name: "tty output",
245 tty: true,
246 opts: ListOptions{
247 State: stateOpen,
248 Limit: 30,
249 Sort: sortUpdated,
250 Order: orderDesc,
251 },
252 clientStub: func(t *testing.T, m *client.DiscussionClientMock) {
253 m.ListFunc = func(repo ghrepo.Interface, filters client.ListFilters, after string, limit int) (*client.DiscussionListResult, error) {
254 return sampleResult(), nil
255 }
256 },
257 wantStdout: heredoc.Doc(`
258
259 Showing 2 of 2 open discussions in OWNER/REPO
260
261 ID TITLE CATEGORY LABELS ANSWERED UPDATED
262 #42 Bug report discussion General bug ✓ about 12 hours ago
263 #41 Feature request Ideas about 8 days ago
264 `),
265 },
266 {
267 name: "non-tty output",
268 tty: false,
269 opts: ListOptions{
270 State: stateOpen,
271 Limit: 30,
272 Sort: sortUpdated,
273 Order: orderDesc,
274 },
275 clientStub: func(t *testing.T, m *client.DiscussionClientMock) {
276 m.ListFunc = func(repo ghrepo.Interface, filters client.ListFilters, after string, limit int) (*client.DiscussionListResult, error) {
277 return sampleResult(), nil
278 }
279 },
280 wantStdout: heredoc.Doc(`
281 42 OPEN Bug report discussion General bug answered 2025-02-28T12:00:00Z
282 41 OPEN Feature request Ideas 2025-02-20T12:00:00Z
283 `),
284 },
285 {
286 name: "json output with next cursor",
287 opts: ListOptions{
288 State: stateOpen,

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
NewJSONExporterFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
sampleResultFunction · 0.85
sampleDiscussionsFunction · 0.85
SetFieldsMethod · 0.80
EqualMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
ContainsMethod · 0.80
sampleCategoriesFunction · 0.70

Tested by

no test coverage detected