MCPcopy Create free account
hub / github.com/cli/cli / TestIssueCreate_recover

Function TestIssueCreate_recover

pkg/cmd/issue/create/create_test.go:1569–1651  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1567}
1568
1569func TestIssueCreate_recover(t *testing.T) {
1570 http := &httpmock.Registry{}
1571 defer http.Verify(t)
1572
1573 http.Register(
1574 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1575 httpmock.StringResponse(`
1576 { "data": { "repository": {
1577 "id": "REPOID",
1578 "hasIssuesEnabled": true
1579 } } }`))
1580 // Should only be one fetch of metadata.
1581 http.Register(
1582 httpmock.GraphQL(`query RepositoryLabelList\b`),
1583 httpmock.StringResponse(`
1584 { "data": { "repository": { "labels": {
1585 "nodes": [
1586 { "name": "TODO", "id": "TODOID" },
1587 { "name": "bug", "id": "BUGID" }
1588 ],
1589 "pageInfo": { "hasNextPage": false }
1590 } } } }
1591 `))
1592 http.Register(
1593 httpmock.GraphQL(`mutation IssueCreate\b`),
1594 httpmock.GraphQLMutation(`
1595 { "data": { "createIssue": { "issue": {
1596 "URL": "https://github.com/OWNER/REPO/issues/12"
1597 } } } }
1598 `, func(inputs map[string]any) {
1599 assert.Equal(t, "recovered title", inputs["title"])
1600 assert.Equal(t, "recovered body", inputs["body"])
1601 assert.Equal(t, []any{"BUGID", "TODOID"}, inputs["labelIds"])
1602 }))
1603
1604 pm := &prompter.PrompterMock{}
1605 pm.InputFunc = func(p, d string) (string, error) {
1606 if p == "Title (required)" {
1607 return d, nil
1608 } else {
1609 return "", prompter.NoSuchPromptErr(p)
1610 }
1611 }
1612 pm.MarkdownEditorFunc = func(p, d string, ba bool) (string, error) {
1613 if p == "Body" {
1614 return d, nil
1615 } else {
1616 return "", prompter.NoSuchPromptErr(p)
1617 }
1618 }
1619 pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
1620 if p == "What's next?" {
1621 return prompter.IndexFor(opts, "Submit")
1622 } else {
1623 return -1, prompter.NoSuchPromptErr(p)
1624 }
1625 }
1626

Callers

nothing calls this directly

Calls 14

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
GraphQLMutationFunction · 0.92
NoSuchPromptErrFunction · 0.92
IndexForFunction · 0.92
EqualMethod · 0.80
CloseMethod · 0.65
WriteMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected