(t *testing.T)
| 283 | } |
| 284 | |
| 285 | func TestViewRun(t *testing.T) { |
| 286 | fixedNow := func() time.Time { return time.Date(2025, 3, 1, 1, 0, 0, 0, time.UTC) } |
| 287 | |
| 288 | tests := []struct { |
| 289 | name string |
| 290 | tty bool |
| 291 | clientStub func(*testing.T, *client.DiscussionClientMock) |
| 292 | opts ViewOptions |
| 293 | wantStdout string |
| 294 | wantStderr string |
| 295 | wantBrowser string |
| 296 | }{ |
| 297 | { |
| 298 | name: "tty", |
| 299 | tty: true, |
| 300 | clientStub: func(t *testing.T, m *client.DiscussionClientMock) { |
| 301 | m.GetByNumberFunc = func(repo ghrepo.Interface, number int32) (*client.Discussion, error) { |
| 302 | assert.Equal(t, "OWNER/REPO", ghrepo.FullName(repo)) |
| 303 | assert.Equal(t, int32(123), number) |
| 304 | return exampleAnswerableDiscussion(), nil |
| 305 | } |
| 306 | }, |
| 307 | wantStdout: heredoc.Doc(` |
| 308 | an interesting question #123 |
| 309 | Open • Q&A • Asked by monalisa • about 1 hour ago • 3 comments |
| 310 | Labels: help-wanted |
| 311 | |
| 312 | |
| 313 | about my interesting question |
| 314 | |
| 315 | |
| 316 | 👍 5 • 🚀 2 |
| 317 | |
| 318 | View this discussion on GitHub: https://github.com/OWNER/REPO/discussions/123 |
| 319 | `), |
| 320 | }, |
| 321 | { |
| 322 | name: "nontty", |
| 323 | clientStub: func(t *testing.T, m *client.DiscussionClientMock) { |
| 324 | m.GetByNumberFunc = func(repo ghrepo.Interface, number int32) (*client.Discussion, error) { |
| 325 | assert.Equal(t, "OWNER/REPO", ghrepo.FullName(repo)) |
| 326 | assert.Equal(t, int32(123), number) |
| 327 | return exampleAnswerableDiscussion(), nil |
| 328 | } |
| 329 | }, |
| 330 | wantStdout: heredoc.Doc(` |
| 331 | title: an interesting question |
| 332 | state: OPEN |
| 333 | category: Q&A |
| 334 | author: monalisa |
| 335 | labels: help-wanted |
| 336 | comments: 3 |
| 337 | number: 123 |
| 338 | url: https://github.com/OWNER/REPO/discussions/123 |
| 339 | -- |
| 340 | about my interesting question |
| 341 | `), |
| 342 | }, |
nothing calls this directly
no test coverage detected