MCPcopy Create free account
hub / github.com/cli/cli / TestIssueCreate_continueInBrowser

Function TestIssueCreate_continueInBrowser

pkg/cmd/issue/create/create_test.go:1716–1761  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1714}
1715
1716func TestIssueCreate_continueInBrowser(t *testing.T) {
1717 http := &httpmock.Registry{}
1718 defer http.Verify(t)
1719
1720 http.Register(
1721 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1722 httpmock.StringResponse(`
1723 { "data": { "repository": {
1724 "id": "REPOID",
1725 "hasIssuesEnabled": true
1726 } } }`),
1727 )
1728
1729 pm := &prompter.PrompterMock{}
1730 pm.InputFunc = func(p, d string) (string, error) {
1731 if p == "Title (required)" {
1732 return "hello", nil
1733 } else {
1734 return "", prompter.NoSuchPromptErr(p)
1735 }
1736 }
1737 pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
1738 if p == "What's next?" {
1739 return prompter.IndexFor(opts, "Continue in browser")
1740 } else {
1741 return -1, prompter.NoSuchPromptErr(p)
1742 }
1743 }
1744
1745 _, cmdTeardown := run.Stub()
1746 defer cmdTeardown(t)
1747
1748 output, err := runCommand(http, true, `-b body`, pm)
1749 if err != nil {
1750 t.Errorf("error running command `issue create`: %v", err)
1751 }
1752
1753 assert.Equal(t, "", output.String())
1754 assert.Equal(t, heredoc.Doc(`
1755
1756 Creating issue in OWNER/REPO
1757
1758 Opening https://github.com/OWNER/REPO/issues/new in your browser.
1759 `), output.Stderr())
1760 assert.Equal(t, "https://github.com/OWNER/REPO/issues/new?body=body&title=hello", output.BrowsedURL)
1761}
1762
1763func TestIssueCreate_metadata(t *testing.T) {
1764 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NoSuchPromptErrFunction · 0.92
IndexForFunction · 0.92
StubFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
runCommandFunction · 0.70
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected