(t *testing.T)
| 1655 | } |
| 1656 | |
| 1657 | func TestIssueCreate_continueInBrowser(t *testing.T) { |
| 1658 | http := &httpmock.Registry{} |
| 1659 | defer http.Verify(t) |
| 1660 | |
| 1661 | http.Register( |
| 1662 | httpmock.GraphQL(`query IssueRepositoryInfo\b`), |
| 1663 | httpmock.StringResponse(` |
| 1664 | { "data": { "repository": { |
| 1665 | "id": "REPOID", |
| 1666 | "hasIssuesEnabled": true |
| 1667 | } } }`), |
| 1668 | ) |
| 1669 | |
| 1670 | pm := &prompter.PrompterMock{} |
| 1671 | pm.InputFunc = func(p, d string) (string, error) { |
| 1672 | if p == "Title (required)" { |
| 1673 | return "hello", nil |
| 1674 | } else { |
| 1675 | return "", prompter.NoSuchPromptErr(p) |
| 1676 | } |
| 1677 | } |
| 1678 | pm.SelectFunc = func(p, _ string, opts []string) (int, error) { |
| 1679 | if p == "What's next?" { |
| 1680 | return prompter.IndexFor(opts, "Continue in browser") |
| 1681 | } else { |
| 1682 | return -1, prompter.NoSuchPromptErr(p) |
| 1683 | } |
| 1684 | } |
| 1685 | |
| 1686 | _, cmdTeardown := run.Stub() |
| 1687 | defer cmdTeardown(t) |
| 1688 | |
| 1689 | output, err := runCommand(http, true, `-b body`, pm) |
| 1690 | if err != nil { |
| 1691 | t.Errorf("error running command `issue create`: %v", err) |
| 1692 | } |
| 1693 | |
| 1694 | assert.Equal(t, "", output.String()) |
| 1695 | assert.Equal(t, heredoc.Doc(` |
| 1696 | |
| 1697 | Creating issue in OWNER/REPO |
| 1698 | |
| 1699 | Opening https://github.com/OWNER/REPO/issues/new in your browser. |
| 1700 | `), output.Stderr()) |
| 1701 | assert.Equal(t, "https://github.com/OWNER/REPO/issues/new?body=body&title=hello", output.BrowsedURL) |
| 1702 | } |
| 1703 | |
| 1704 | func TestIssueCreate_metadata(t *testing.T) { |
| 1705 | http := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected