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