MCPcopy Index your code
hub / github.com/cli/cli / TestIssueCreate

Function TestIssueCreate

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

Source from the content-addressed store, hash-verified

1023}
1024
1025func TestIssueCreate(t *testing.T) {
1026 http := &httpmock.Registry{}
1027 defer http.Verify(t)
1028
1029 http.Register(
1030 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1031 httpmock.StringResponse(`
1032 { "data": { "repository": {
1033 "id": "REPOID",
1034 "hasIssuesEnabled": true
1035 } } }`),
1036 )
1037 http.Register(
1038 httpmock.GraphQL(`mutation IssueCreate\b`),
1039 httpmock.GraphQLMutation(`
1040 { "data": { "createIssue": { "issue": {
1041 "URL": "https://github.com/OWNER/REPO/issues/12"
1042 } } } }`,
1043 func(inputs map[string]interface{}) {
1044 assert.Equal(t, inputs["repositoryId"], "REPOID")
1045 assert.Equal(t, inputs["title"], "hello")
1046 assert.Equal(t, inputs["body"], "cash rules everything around me")
1047 }),
1048 )
1049
1050 output, err := runCommand(http, true, `-t hello -b "cash rules everything around me"`, nil)
1051 if err != nil {
1052 t.Errorf("error running command `issue create`: %v", err)
1053 }
1054
1055 assert.Equal(t, "https://github.com/OWNER/REPO/issues/12\n", output.String())
1056}
1057
1058func TestIssueCreate_recover(t *testing.T) {
1059 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.45

Tested by

no test coverage detected