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

Function TestIssueCreate_recover

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

Source from the content-addressed store, hash-verified

1523}
1524
1525func TestIssueCreate_recover(t *testing.T) {
1526 http := &httpmock.Registry{}
1527 defer http.Verify(t)
1528
1529 http.Register(
1530 httpmock.GraphQL(`query IssueRepositoryInfo\b`),
1531 httpmock.StringResponse(`
1532 { "data": { "repository": {
1533 "id": "REPOID",
1534 "hasIssuesEnabled": true
1535 } } }`))
1536 // Should only be one fetch of metadata.
1537 http.Register(
1538 httpmock.GraphQL(`query RepositoryLabelList\b`),
1539 httpmock.StringResponse(`
1540 { "data": { "repository": { "labels": {
1541 "nodes": [
1542 { "name": "TODO", "id": "TODOID" },
1543 { "name": "bug", "id": "BUGID" }
1544 ],
1545 "pageInfo": { "hasNextPage": false }
1546 } } } }
1547 `))
1548 http.Register(
1549 httpmock.GraphQL(`mutation IssueCreate\b`),
1550 httpmock.GraphQLMutation(`
1551 { "data": { "createIssue": { "issue": {
1552 "URL": "https://github.com/OWNER/REPO/issues/12"
1553 } } } }
1554 `, func(inputs map[string]any) {
1555 assert.Equal(t, "recovered title", inputs["title"])
1556 assert.Equal(t, "recovered body", inputs["body"])
1557 assert.Equal(t, []any{"BUGID", "TODOID"}, inputs["labelIds"])
1558 }))
1559
1560 pm := &prompter.PrompterMock{}
1561 pm.InputFunc = func(p, d string) (string, error) {
1562 if p == "Title (required)" {
1563 return d, nil
1564 } else {
1565 return "", prompter.NoSuchPromptErr(p)
1566 }
1567 }
1568 pm.MarkdownEditorFunc = func(p, d string, ba bool) (string, error) {
1569 if p == "Body" {
1570 return d, nil
1571 } else {
1572 return "", prompter.NoSuchPromptErr(p)
1573 }
1574 }
1575 pm.SelectFunc = func(p, _ string, opts []string) (int, error) {
1576 if p == "What's next?" {
1577 return prompter.IndexFor(opts, "Submit")
1578 } else {
1579 return -1, prompter.NoSuchPromptErr(p)
1580 }
1581 }
1582

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