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

Function TestIssueCreate

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

Source from the content-addressed store, hash-verified

1517}
1518
1519func TestIssueCreate(t *testing.T) {
1520 http := &httpmock.Registry{}
1521 defer http.Verify(t)
1522
1523 http.Register(
1524 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1525 httpmock.StringResponse(`
1526 { "data": { "repository": {
1527 "id": "REPOID",
1528 "hasIssuesEnabled": true
1529 } } }`),
1530 )
1531 http.Register(
1532 httpmock.GraphQL(`mutation IssueCreate\b`),
1533 httpmock.GraphQLMutation(`
1534 { "data": { "createIssue": { "issue": {
1535 "URL": "https://github.com/OWNER/REPO/issues/12"
1536 } } } }`,
1537 func(inputs map[string]any) {
1538 assert.Equal(t, inputs["repositoryId"], "REPOID")
1539 assert.Equal(t, inputs["title"], "hello")
1540 assert.Equal(t, inputs["body"], "cash rules everything around me")
1541 }),
1542 )
1543
1544 output, err := runCommand(http, true, `-t hello -b "cash rules everything around me"`, nil)
1545 if err != nil {
1546 t.Errorf("error running command `issue create`: %v", err)
1547 }
1548
1549 assert.Equal(t, "https://github.com/OWNER/REPO/issues/12\n", output.String())
1550}
1551
1552func TestIssueCreate_recover(t *testing.T) {
1553 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