MCPcopy
hub / github.com/cli/cli / TestIssueCreate_recover

Function TestIssueCreate_recover

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

Source from the content-addressed store, hash-verified

1056}
1057
1058func TestIssueCreate_recover(t *testing.T) {
1059 http := &httpmock.Registry{}
1060 defer http.Verify(t)
1061
1062 http.Register(
1063 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1064 httpmock.StringResponse(`
1065 { "data": { "repository": {
1066 "id": "REPOID",
1067 "hasIssuesEnabled": true
1068 } } }`))
1069 // Should only be one fetch of metadata.
1070 http.Register(
1071 httpmock.GraphQL(`query RepositoryLabelList\b`),
1072 httpmock.StringResponse(`
1073 { "data": { "repository": { "labels": {
1074 "nodes": [
1075 { "name": "TODO", "id": "TODOID" },
1076 { "name": "bug", "id": "BUGID" }
1077 ],
1078 "pageInfo": { "hasNextPage": false }
1079 } } } }
1080 `))
1081 http.Register(
1082 httpmock.GraphQL(`mutation IssueCreate\b`),
1083 httpmock.GraphQLMutation(`
1084 { "data": { "createIssue": { "issue": {
1085 "URL": "https://github.com/OWNER/REPO/issues/12"
1086 } } } }
1087 `, func(inputs map[string]interface{}) {
1088 assert.Equal(t, "recovered title", inputs["title"])
1089 assert.Equal(t, "recovered body", inputs["body"])
1090 assert.Equal(t, []interface{}{"BUGID", "TODOID"}, inputs["labelIds"])
1091 }))
1092
1093 pm := &prompter.PrompterMock{}
1094 pm.InputFunc = func(p, d string) (string, error) {
1095 if p == "Title (required)" {
1096 return d, nil
1097 } else {
1098 return "", prompter.NoSuchPromptErr(p)
1099 }
1100 }
1101 pm.MarkdownEditorFunc = func(p, d string, ba bool) (string, error) {
1102 if p == "Body" {
1103 return d, nil
1104 } else {
1105 return "", prompter.NoSuchPromptErr(p)
1106 }
1107 }
1108 pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
1109 if p == "What's next?" {
1110 return prompter.IndexFor(opts, "Submit")
1111 } else {
1112 return -1, prompter.NoSuchPromptErr(p)
1113 }
1114 }
1115

Callers

nothing calls this directly

Calls 14

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
GraphQLMutationFunction · 0.92
NoSuchPromptErrFunction · 0.92
IndexForFunction · 0.92
EqualMethod · 0.80
CloseMethod · 0.65
WriteMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected