(t *testing.T)
| 1203 | } |
| 1204 | |
| 1205 | func TestIssueCreate_continueInBrowser(t *testing.T) { |
| 1206 | http := &httpmock.Registry{} |
| 1207 | defer http.Verify(t) |
| 1208 | |
| 1209 | http.Register( |
| 1210 | httpmock.GraphQL(`query IssueRepositoryInfo\b`), |
| 1211 | httpmock.StringResponse(` |
| 1212 | { "data": { "repository": { |
| 1213 | "id": "REPOID", |
| 1214 | "hasIssuesEnabled": true |
| 1215 | } } }`), |
| 1216 | ) |
| 1217 | |
| 1218 | pm := &prompter.PrompterMock{} |
| 1219 | pm.InputFunc = func(p, d string) (string, error) { |
| 1220 | if p == "Title (required)" { |
| 1221 | return "hello", nil |
| 1222 | } else { |
| 1223 | return "", prompter.NoSuchPromptErr(p) |
| 1224 | } |
| 1225 | } |
| 1226 | pm.SelectFunc = func(p, _ string, opts []string) (int, error) { |
| 1227 | if p == "What's next?" { |
| 1228 | return prompter.IndexFor(opts, "Continue in browser") |
| 1229 | } else { |
| 1230 | return -1, prompter.NoSuchPromptErr(p) |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | _, cmdTeardown := run.Stub() |
| 1235 | defer cmdTeardown(t) |
| 1236 | |
| 1237 | output, err := runCommand(http, true, `-b body`, pm) |
| 1238 | if err != nil { |
| 1239 | t.Errorf("error running command `issue create`: %v", err) |
| 1240 | } |
| 1241 | |
| 1242 | assert.Equal(t, "", output.String()) |
| 1243 | assert.Equal(t, heredoc.Doc(` |
| 1244 | |
| 1245 | Creating issue in OWNER/REPO |
| 1246 | |
| 1247 | Opening https://github.com/OWNER/REPO/issues/new in your browser. |
| 1248 | `), output.Stderr()) |
| 1249 | assert.Equal(t, "https://github.com/OWNER/REPO/issues/new?body=body&title=hello", output.BrowsedURL) |
| 1250 | } |
| 1251 | |
| 1252 | func TestIssueCreate_metadata(t *testing.T) { |
| 1253 | http := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected