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

Function TestIssueCreate_continueInBrowser

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

Source from the content-addressed store, hash-verified

1697}
1698
1699func 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
1746func TestIssueCreate_metadata(t *testing.T) {
1747 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