(t *testing.T)
| 1056 | } |
| 1057 | |
| 1058 | func 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 |
nothing calls this directly
no test coverage detected