(t *testing.T)
| 1508 | } |
| 1509 | |
| 1510 | func TestIssueCreate_recover(t *testing.T) { |
| 1511 | http := &httpmock.Registry{} |
| 1512 | defer http.Verify(t) |
| 1513 | |
| 1514 | http.Register( |
| 1515 | httpmock.GraphQL(`query IssueRepositoryInfo\b`), |
| 1516 | httpmock.StringResponse(` |
| 1517 | { "data": { "repository": { |
| 1518 | "id": "REPOID", |
| 1519 | "hasIssuesEnabled": true |
| 1520 | } } }`)) |
| 1521 | // Should only be one fetch of metadata. |
| 1522 | http.Register( |
| 1523 | httpmock.GraphQL(`query RepositoryLabelList\b`), |
| 1524 | httpmock.StringResponse(` |
| 1525 | { "data": { "repository": { "labels": { |
| 1526 | "nodes": [ |
| 1527 | { "name": "TODO", "id": "TODOID" }, |
| 1528 | { "name": "bug", "id": "BUGID" } |
| 1529 | ], |
| 1530 | "pageInfo": { "hasNextPage": false } |
| 1531 | } } } } |
| 1532 | `)) |
| 1533 | http.Register( |
| 1534 | httpmock.GraphQL(`mutation IssueCreate\b`), |
| 1535 | httpmock.GraphQLMutation(` |
| 1536 | { "data": { "createIssue": { "issue": { |
| 1537 | "URL": "https://github.com/OWNER/REPO/issues/12" |
| 1538 | } } } } |
| 1539 | `, func(inputs map[string]any) { |
| 1540 | assert.Equal(t, "recovered title", inputs["title"]) |
| 1541 | assert.Equal(t, "recovered body", inputs["body"]) |
| 1542 | assert.Equal(t, []any{"BUGID", "TODOID"}, inputs["labelIds"]) |
| 1543 | })) |
| 1544 | |
| 1545 | pm := &prompter.PrompterMock{} |
| 1546 | pm.InputFunc = func(p, d string) (string, error) { |
| 1547 | if p == "Title (required)" { |
| 1548 | return d, nil |
| 1549 | } else { |
| 1550 | return "", prompter.NoSuchPromptErr(p) |
| 1551 | } |
| 1552 | } |
| 1553 | pm.MarkdownEditorFunc = func(p, d string, ba bool) (string, error) { |
| 1554 | if p == "Body" { |
| 1555 | return d, nil |
| 1556 | } else { |
| 1557 | return "", prompter.NoSuchPromptErr(p) |
| 1558 | } |
| 1559 | } |
| 1560 | pm.SelectFunc = func(p, _ string, opts []string) (int, error) { |
| 1561 | if p == "What's next?" { |
| 1562 | return prompter.IndexFor(opts, "Submit") |
| 1563 | } else { |
| 1564 | return -1, prompter.NoSuchPromptErr(p) |
| 1565 | } |
| 1566 | } |
| 1567 |
nothing calls this directly
no test coverage detected