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