MCPcopy
hub / github.com/cli/cli / TestIssueCreate_continueInBrowser

Function TestIssueCreate_continueInBrowser

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

Source from the content-addressed store, hash-verified

1203}
1204
1205func TestIssueCreate_continueInBrowser(t *testing.T) {
1206 http := &httpmock.Registry{}
1207 defer http.Verify(t)
1208
1209 http.Register(
1210 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1211 httpmock.StringResponse(`
1212 { "data": { "repository": {
1213 "id": "REPOID",
1214 "hasIssuesEnabled": true
1215 } } }`),
1216 )
1217
1218 pm := &prompter.PrompterMock{}
1219 pm.InputFunc = func(p, d string) (string, error) {
1220 if p == "Title (required)" {
1221 return "hello", nil
1222 } else {
1223 return "", prompter.NoSuchPromptErr(p)
1224 }
1225 }
1226 pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
1227 if p == "What's next?" {
1228 return prompter.IndexFor(opts, "Continue in browser")
1229 } else {
1230 return -1, prompter.NoSuchPromptErr(p)
1231 }
1232 }
1233
1234 _, cmdTeardown := run.Stub()
1235 defer cmdTeardown(t)
1236
1237 output, err := runCommand(http, true, `-b body`, pm)
1238 if err != nil {
1239 t.Errorf("error running command `issue create`: %v", err)
1240 }
1241
1242 assert.Equal(t, "", output.String())
1243 assert.Equal(t, heredoc.Doc(`
1244
1245 Creating issue in OWNER/REPO
1246
1247 Opening https://github.com/OWNER/REPO/issues/new in your browser.
1248 `), output.Stderr())
1249 assert.Equal(t, "https://github.com/OWNER/REPO/issues/new?body=body&title=hello", output.BrowsedURL)
1250}
1251
1252func TestIssueCreate_metadata(t *testing.T) {
1253 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.45

Tested by

no test coverage detected