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

Function TestIssueCreate_continueInBrowser

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

Source from the content-addressed store, hash-verified

1670}
1671
1672func 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
1719func TestIssueCreate_metadata(t *testing.T) {
1720 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