(t *testing.T)
| 568 | } |
| 569 | |
| 570 | func TestCreateRun(t *testing.T) { |
| 571 | apiError := func(status int, message string) error { |
| 572 | u, err := url.Parse("https://api.github.com/repos/monalisa/monas-cafe/issues/142/artifacts") |
| 573 | require.NoError(t, err) |
| 574 | return api.HTTPError{HTTPError: &ghAPI.HTTPError{StatusCode: status, Message: message, RequestURL: u}} |
| 575 | } |
| 576 | uploaded := func(name, asset string) attachments.UploadStub { |
| 577 | return attachments.UploadStub{Name: name, Status: 200, Body: fmt.Sprintf(`{"url": "https://github.com/user-attachments/assets/%s"}`, asset)} |
| 578 | } |
| 579 | const ( |
| 580 | signinPlan = "# Sign-in plan\n\n1. Register the callback URL.\n" |
| 581 | oauthResearch = "# OAuth research\n\nGitHub is the only provider we need for now.\n" |
| 582 | signinPlanFlow = "# Sign-in plan\n\n\n" |
| 583 | baristaFlow = "# Barista notes\n\nThe flow in  confused them.\n" |
| 584 | shortcut = "[InternetShortcut]\r\nURL=" + runbookURL + "\r\n" |
| 585 | menuHTML = "<!doctype html>\n<html>\n<body><h1>Seasonal menu</h1><p>Maple oat latte</p></body>\n</html>\n" |
| 586 | // menuHTMLFlow would have its Markdown reference replaced, were it a |
| 587 | // Markdown document. |
| 588 | menuHTMLFlow = "<h1>Seasonal menu</h1>\n\n\n" |
| 589 | ) |
| 590 | |
| 591 | tests := []struct { |
| 592 | name string |
| 593 | repo ghrepo.Interface |
| 594 | files map[string]string |
| 595 | symlinks map[string]string |
| 596 | attach []string |
| 597 | uploads []attachments.UploadStub |
| 598 | stdin string |
| 599 | opts CreateOptions |
| 600 | tty bool |
| 601 | color bool |
| 602 | isPullRequest bool |
| 603 | lookupErr error |
| 604 | permission string |
| 605 | createErrs map[string]error |
| 606 | wantCalls []string |
| 607 | wantBodies []string |
| 608 | wantOps *attachments.UploadResult |
| 609 | wantStdout string |
| 610 | wantStderr string |
| 611 | wantErr string |
| 612 | wantErrIs error |
| 613 | }{ |
| 614 | { |
| 615 | name: "a file, named after the file", |
| 616 | files: map[string]string{"signin-plan.md": signinPlan}, |
| 617 | opts: CreateOptions{Sources: []source{{kind: fromFile, arg: "signin-plan.md"}}}, |
| 618 | tty: true, |
| 619 | wantCalls: []string{ |
| 620 | "IsPullRequest monalisa/monas-cafe#142", |
| 621 | `Create monalisa/monas-cafe#142 generic "signin-plan.md"`, |
| 622 | }, |
| 623 | wantBodies: []string{signinPlan}, |
| 624 | wantStdout: "✓ Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142\n", |
| 625 | }, |
| 626 | { |
| 627 | name: "a file with #<name>", |
nothing calls this directly
no test coverage detected