(t *testing.T)
| 1697 | } |
| 1698 | |
| 1699 | func TestIssueCreate_continueInBrowser(t *testing.T) { |
| 1700 | http := &httpmock.Registry{} |
| 1701 | defer http.Verify(t) |
| 1702 | |
| 1703 | http.Register( |
| 1704 | httpmock.GraphQL(`query IssueRepositoryInfo\b`), |
| 1705 | httpmock.StringResponse(` |
| 1706 | { "data": { "repository": { |
| 1707 | "id": "REPOID", |
| 1708 | "hasIssuesEnabled": true |
| 1709 | } } }`), |
| 1710 | ) |
| 1711 | |
| 1712 | pm := &prompter.PrompterMock{} |
| 1713 | pm.InputFunc = func(p, d string) (string, error) { |
| 1714 | if p == "Title (required)" { |
| 1715 | return "hello", nil |
| 1716 | } else { |
| 1717 | return "", prompter.NoSuchPromptErr(p) |
| 1718 | } |
| 1719 | } |
| 1720 | pm.SelectFunc = func(p, _ string, opts []string) (int, error) { |
| 1721 | if p == "What's next?" { |
| 1722 | return prompter.IndexFor(opts, "Continue in browser") |
| 1723 | } else { |
| 1724 | return -1, prompter.NoSuchPromptErr(p) |
| 1725 | } |
| 1726 | } |
| 1727 | |
| 1728 | _, cmdTeardown := run.Stub() |
| 1729 | defer cmdTeardown(t) |
| 1730 | |
| 1731 | output, err := runCommand(http, true, `-b body`, pm) |
| 1732 | if err != nil { |
| 1733 | t.Errorf("error running command `issue create`: %v", err) |
| 1734 | } |
| 1735 | |
| 1736 | assert.Equal(t, "", output.String()) |
| 1737 | assert.Equal(t, heredoc.Doc(` |
| 1738 | |
| 1739 | Creating issue in OWNER/REPO |
| 1740 | |
| 1741 | Opening https://github.com/OWNER/REPO/issues/new in your browser. |
| 1742 | `), output.Stderr()) |
| 1743 | assert.Equal(t, "https://github.com/OWNER/REPO/issues/new?body=body&title=hello", output.BrowsedURL) |
| 1744 | } |
| 1745 | |
| 1746 | func TestIssueCreate_metadata(t *testing.T) { |
| 1747 | http := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected