(t *testing.T)
| 298 | } |
| 299 | |
| 300 | func Test_commentRun(t *testing.T) { |
| 301 | tests := []struct { |
| 302 | name string |
| 303 | input *shared.CommentableOptions |
| 304 | emptyComments bool |
| 305 | comments api.Comments |
| 306 | httpStubs func(*testing.T, *httpmock.Registry) |
| 307 | stdout string |
| 308 | stderr string |
| 309 | wantsErr bool |
| 310 | }{ |
| 311 | { |
| 312 | name: "creating new comment with interactive editor succeeds", |
| 313 | input: &shared.CommentableOptions{ |
| 314 | Interactive: true, |
| 315 | InputType: 0, |
| 316 | Body: "", |
| 317 | |
| 318 | InteractiveEditSurvey: func(string) (string, error) { return "comment body", nil }, |
| 319 | ConfirmSubmitSurvey: func() (bool, error) { return true, nil }, |
| 320 | }, |
| 321 | emptyComments: true, |
| 322 | httpStubs: func(t *testing.T, reg *httpmock.Registry) { |
| 323 | mockCommentCreate(t, reg) |
| 324 | }, |
| 325 | stdout: "https://github.com/OWNER/REPO/issues/123#issuecomment-456\n", |
| 326 | }, |
| 327 | { |
| 328 | name: "updating last comment with interactive editor fails if there are no comments and decline prompt to create", |
| 329 | input: &shared.CommentableOptions{ |
| 330 | Interactive: true, |
| 331 | InputType: 0, |
| 332 | Body: "", |
| 333 | EditLast: true, |
| 334 | |
| 335 | InteractiveEditSurvey: func(string) (string, error) { return "comment body", nil }, |
| 336 | ConfirmSubmitSurvey: func() (bool, error) { return true, nil }, |
| 337 | ConfirmCreateIfNoneSurvey: func() (bool, error) { return false, nil }, |
| 338 | }, |
| 339 | emptyComments: true, |
| 340 | wantsErr: true, |
| 341 | stdout: "no comments found for current user", |
| 342 | }, |
| 343 | { |
| 344 | name: "updating last comment with interactive editor succeeds if there are comments", |
| 345 | input: &shared.CommentableOptions{ |
| 346 | Interactive: true, |
| 347 | InputType: 0, |
| 348 | Body: "", |
| 349 | EditLast: true, |
| 350 | |
| 351 | InteractiveEditSurvey: func(string) (string, error) { return "comment body", nil }, |
| 352 | ConfirmSubmitSurvey: func() (bool, error) { return true, nil }, |
| 353 | }, |
| 354 | httpStubs: func(t *testing.T, reg *httpmock.Registry) { |
| 355 | mockCommentUpdate(t, reg) |
| 356 | }, |
| 357 | emptyComments: false, |
nothing calls this directly
no test coverage detected