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

Function TestIssueCreate

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

Source from the content-addressed store, hash-verified

1534}
1535
1536func TestIssueCreate(t *testing.T) {
1537 http := &httpmock.Registry{}
1538 defer http.Verify(t)
1539
1540 http.Register(
1541 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1542 httpmock.StringResponse(`
1543 { "data": { "repository": {
1544 "id": "REPOID",
1545 "hasIssuesEnabled": true
1546 } } }`),
1547 )
1548 http.Register(
1549 httpmock.GraphQL(`mutation IssueCreate\b`),
1550 httpmock.GraphQLMutation(`
1551 { "data": { "createIssue": { "issue": {
1552 "URL": "https://github.com/OWNER/REPO/issues/12"
1553 } } } }`,
1554 func(inputs map[string]any) {
1555 assert.Equal(t, inputs["repositoryId"], "REPOID")
1556 assert.Equal(t, inputs["title"], "hello")
1557 assert.Equal(t, inputs["body"], "cash rules everything around me")
1558 }),
1559 )
1560
1561 output, err := runCommand(http, true, `-t hello -b "cash rules everything around me"`, nil)
1562 if err != nil {
1563 t.Errorf("error running command `issue create`: %v", err)
1564 }
1565
1566 assert.Equal(t, "https://github.com/OWNER/REPO/issues/12\n", output.String())
1567}
1568
1569func TestIssueCreate_recover(t *testing.T) {
1570 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