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

Function TestIssueCreate

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

Source from the content-addressed store, hash-verified

1475}
1476
1477func TestIssueCreate(t *testing.T) {
1478 http := &httpmock.Registry{}
1479 defer http.Verify(t)
1480
1481 http.Register(
1482 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1483 httpmock.StringResponse(`
1484 { "data": { "repository": {
1485 "id": "REPOID",
1486 "hasIssuesEnabled": true
1487 } } }`),
1488 )
1489 http.Register(
1490 httpmock.GraphQL(`mutation IssueCreate\b`),
1491 httpmock.GraphQLMutation(`
1492 { "data": { "createIssue": { "issue": {
1493 "URL": "https://github.com/OWNER/REPO/issues/12"
1494 } } } }`,
1495 func(inputs map[string]any) {
1496 assert.Equal(t, inputs["repositoryId"], "REPOID")
1497 assert.Equal(t, inputs["title"], "hello")
1498 assert.Equal(t, inputs["body"], "cash rules everything around me")
1499 }),
1500 )
1501
1502 output, err := runCommand(http, true, `-t hello -b "cash rules everything around me"`, nil)
1503 if err != nil {
1504 t.Errorf("error running command `issue create`: %v", err)
1505 }
1506
1507 assert.Equal(t, "https://github.com/OWNER/REPO/issues/12\n", output.String())
1508}
1509
1510func TestIssueCreate_recover(t *testing.T) {
1511 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
GraphQLMutationFunction · 0.92
EqualMethod · 0.80
runCommandFunction · 0.70
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected