(t *testing.T)
| 1607 | } |
| 1608 | |
| 1609 | func TestIssueCreate_nonLegacyTemplate(t *testing.T) { |
| 1610 | http := &httpmock.Registry{} |
| 1611 | defer http.Verify(t) |
| 1612 | |
| 1613 | http.Register( |
| 1614 | httpmock.GraphQL(`query IssueRepositoryInfo\b`), |
| 1615 | httpmock.StringResponse(` |
| 1616 | { "data": { "repository": { |
| 1617 | "id": "REPOID", |
| 1618 | "hasIssuesEnabled": true |
| 1619 | } } }`), |
| 1620 | ) |
| 1621 | http.Register( |
| 1622 | httpmock.GraphQL(`query IssueTemplates\b`), |
| 1623 | httpmock.StringResponse(` |
| 1624 | { "data": { "repository": { "issueTemplates": [ |
| 1625 | { "name": "Bug report", |
| 1626 | "body": "Does not work :((" }, |
| 1627 | { "name": "Submit a request", |
| 1628 | "body": "I have a suggestion for an enhancement" } |
| 1629 | ] } } }`), |
| 1630 | ) |
| 1631 | http.Register( |
| 1632 | httpmock.GraphQL(`mutation IssueCreate\b`), |
| 1633 | httpmock.GraphQLMutation(` |
| 1634 | { "data": { "createIssue": { "issue": { |
| 1635 | "URL": "https://github.com/OWNER/REPO/issues/12" |
| 1636 | } } } }`, |
| 1637 | func(inputs map[string]any) { |
| 1638 | assert.Equal(t, inputs["repositoryId"], "REPOID") |
| 1639 | assert.Equal(t, inputs["title"], "hello") |
| 1640 | assert.Equal(t, inputs["body"], "I have a suggestion for an enhancement") |
| 1641 | }), |
| 1642 | ) |
| 1643 | |
| 1644 | pm := &prompter.PrompterMock{} |
| 1645 | pm.MarkdownEditorFunc = func(p, d string, ba bool) (string, error) { |
| 1646 | if p == "Body" { |
| 1647 | return d, nil |
| 1648 | } else { |
| 1649 | return "", prompter.NoSuchPromptErr(p) |
| 1650 | } |
| 1651 | } |
| 1652 | pm.SelectFunc = func(p, _ string, opts []string) (int, error) { |
| 1653 | switch p { |
| 1654 | case "What's next?": |
| 1655 | return prompter.IndexFor(opts, "Submit") |
| 1656 | case "Choose a template": |
| 1657 | return prompter.IndexFor(opts, "Submit a request") |
| 1658 | default: |
| 1659 | return -1, prompter.NoSuchPromptErr(p) |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | output, err := runCommandWithRootDirOverridden(http, true, `-t hello`, "./fixtures/repoWithNonLegacyIssueTemplates", pm) |
| 1664 | if err != nil { |
| 1665 | t.Errorf("error running command `issue create`: %v", err) |
| 1666 | } |
nothing calls this directly
no test coverage detected