(t *testing.T)
| 390 | } |
| 391 | |
| 392 | func Test_createRun(t *testing.T) { |
| 393 | tests := []struct { |
| 394 | name string |
| 395 | opts CreateOptions |
| 396 | attach []string |
| 397 | host string |
| 398 | httpStubs func(*testing.T, *httpmock.Registry) |
| 399 | promptStubs func(*testing.T, *prompter.PrompterMock) |
| 400 | wantsStdout string |
| 401 | wantsStderr string |
| 402 | wantsBrowse string |
| 403 | wantsErr string |
| 404 | wantOperations *attachments.UploadResult |
| 405 | }{ |
| 406 | { |
| 407 | name: "no args", |
| 408 | opts: CreateOptions{ |
| 409 | Detector: &fd.EnabledDetectorMock{}, |
| 410 | WebMode: true, |
| 411 | }, |
| 412 | wantsBrowse: "https://github.com/OWNER/REPO/issues/new", |
| 413 | wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n", |
| 414 | }, |
| 415 | { |
| 416 | name: "title and body", |
| 417 | opts: CreateOptions{ |
| 418 | Detector: &fd.EnabledDetectorMock{}, |
| 419 | WebMode: true, |
| 420 | Title: "myissue", |
| 421 | Body: "hello cli", |
| 422 | }, |
| 423 | wantsBrowse: "https://github.com/OWNER/REPO/issues/new?body=hello+cli&title=myissue", |
| 424 | wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n", |
| 425 | }, |
| 426 | { |
| 427 | name: "assignee", |
| 428 | opts: CreateOptions{ |
| 429 | Detector: &fd.EnabledDetectorMock{}, |
| 430 | WebMode: true, |
| 431 | Assignees: []string{"monalisa"}, |
| 432 | }, |
| 433 | wantsBrowse: "https://github.com/OWNER/REPO/issues/new?assignees=monalisa&body=", |
| 434 | wantsStderr: "Opening https://github.com/OWNER/REPO/issues/new in your browser.\n", |
| 435 | }, |
| 436 | { |
| 437 | name: "@me", |
| 438 | opts: CreateOptions{ |
| 439 | Detector: &fd.EnabledDetectorMock{}, |
| 440 | WebMode: true, |
| 441 | Assignees: []string{"@me"}, |
| 442 | }, |
| 443 | httpStubs: func(_ *testing.T, r *httpmock.Registry) { |
| 444 | r.Register( |
| 445 | httpmock.GraphQL(`query UserCurrent\b`), |
| 446 | httpmock.StringResponse(` |
| 447 | { "data": { |
| 448 | "viewer": { "login": "MonaLisa" } |
| 449 | } }`)) |
nothing calls this directly
no test coverage detected