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

Function TestIssueCreate_continueInBrowser

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

Source from the content-addressed store, hash-verified

1655}
1656
1657func TestIssueCreate_continueInBrowser(t *testing.T) {
1658 http := &httpmock.Registry{}
1659 defer http.Verify(t)
1660
1661 http.Register(
1662 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1663 httpmock.StringResponse(`
1664 { "data": { "repository": {
1665 "id": "REPOID",
1666 "hasIssuesEnabled": true
1667 } } }`),
1668 )
1669
1670 pm := &prompter.PrompterMock{}
1671 pm.InputFunc = func(p, d string) (string, error) {
1672 if p == "Title (required)" {
1673 return "hello", nil
1674 } else {
1675 return "", prompter.NoSuchPromptErr(p)
1676 }
1677 }
1678 pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
1679 if p == "What's next?" {
1680 return prompter.IndexFor(opts, "Continue in browser")
1681 } else {
1682 return -1, prompter.NoSuchPromptErr(p)
1683 }
1684 }
1685
1686 _, cmdTeardown := run.Stub()
1687 defer cmdTeardown(t)
1688
1689 output, err := runCommand(http, true, `-b body`, pm)
1690 if err != nil {
1691 t.Errorf("error running command `issue create`: %v", err)
1692 }
1693
1694 assert.Equal(t, "", output.String())
1695 assert.Equal(t, heredoc.Doc(`
1696
1697 Creating issue in OWNER/REPO
1698
1699 Opening https://github.com/OWNER/REPO/issues/new in your browser.
1700 `), output.Stderr())
1701 assert.Equal(t, "https://github.com/OWNER/REPO/issues/new?body=body&title=hello", output.BrowsedURL)
1702}
1703
1704func TestIssueCreate_metadata(t *testing.T) {
1705 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