(t *testing.T)
| 1550 | } |
| 1551 | |
| 1552 | func TestIssueCreate_recover(t *testing.T) { |
| 1553 | http := &httpmock.Registry{} |
| 1554 | defer http.Verify(t) |
| 1555 | |
| 1556 | http.Register( |
| 1557 | httpmock.GraphQL(`query IssueRepositoryInfo\b`), |
| 1558 | httpmock.StringResponse(` |
| 1559 | { "data": { "repository": { |
| 1560 | "id": "REPOID", |
| 1561 | "hasIssuesEnabled": true |
| 1562 | } } }`)) |
| 1563 | // Should only be one fetch of metadata. |
| 1564 | http.Register( |
| 1565 | httpmock.GraphQL(`query RepositoryLabelList\b`), |
| 1566 | httpmock.StringResponse(` |
| 1567 | { "data": { "repository": { "labels": { |
| 1568 | "nodes": [ |
| 1569 | { "name": "TODO", "id": "TODOID" }, |
| 1570 | { "name": "bug", "id": "BUGID" } |
| 1571 | ], |
| 1572 | "pageInfo": { "hasNextPage": false } |
| 1573 | } } } } |
| 1574 | `)) |
| 1575 | http.Register( |
| 1576 | httpmock.GraphQL(`mutation IssueCreate\b`), |
| 1577 | httpmock.GraphQLMutation(` |
| 1578 | { "data": { "createIssue": { "issue": { |
| 1579 | "URL": "https://github.com/OWNER/REPO/issues/12" |
| 1580 | } } } } |
| 1581 | `, func(inputs map[string]any) { |
| 1582 | assert.Equal(t, "recovered title", inputs["title"]) |
| 1583 | assert.Equal(t, "recovered body", inputs["body"]) |
| 1584 | assert.Equal(t, []any{"BUGID", "TODOID"}, inputs["labelIds"]) |
| 1585 | })) |
| 1586 | |
| 1587 | pm := &prompter.PrompterMock{} |
| 1588 | pm.InputFunc = func(p, d string) (string, error) { |
| 1589 | if p == "Title (required)" { |
| 1590 | return d, nil |
| 1591 | } else { |
| 1592 | return "", prompter.NoSuchPromptErr(p) |
| 1593 | } |
| 1594 | } |
| 1595 | pm.MarkdownEditorFunc = func(p, d string, ba bool) (string, error) { |
| 1596 | if p == "Body" { |
| 1597 | return d, nil |
| 1598 | } else { |
| 1599 | return "", prompter.NoSuchPromptErr(p) |
| 1600 | } |
| 1601 | } |
| 1602 | pm.SelectFunc = func(p, _ string, opts []string) (int, error) { |
| 1603 | if p == "What's next?" { |
| 1604 | return prompter.IndexFor(opts, "Submit") |
| 1605 | } else { |
| 1606 | return -1, prompter.NoSuchPromptErr(p) |
| 1607 | } |
| 1608 | } |
| 1609 |
nothing calls this directly
no test coverage detected