(t *testing.T)
| 229 | } |
| 230 | |
| 231 | func 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, |
nothing calls this directly
no test coverage detected