MCPcopy
hub / github.com/cli/cli / TestIssueDelete

Function TestIssueDelete

pkg/cmd/issue/delete/delete_test.go:67–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestIssueDelete(t *testing.T) {
68 httpRegistry := &httpmock.Registry{}
69 defer httpRegistry.Verify(t)
70
71 httpRegistry.Register(
72 httpmock.GraphQL(`query IssueByNumber\b`),
73 httpmock.StringResponse(`
74 { "data": { "repository": {
75 "hasIssuesEnabled": true,
76 "issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
77 } } }`),
78 )
79 httpRegistry.Register(
80 httpmock.GraphQL(`mutation IssueDelete\b`),
81 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
82 func(inputs map[string]interface{}) {
83 assert.Equal(t, inputs["issueId"], "THE-ID")
84 }),
85 )
86
87 pm := prompter.NewMockPrompter(t)
88 pm.RegisterConfirmDeletion("13", func(_ string) error { return nil })
89
90 output, err := runCommand(httpRegistry, pm, true, "13")
91 if err != nil {
92 t.Fatalf("error running command `issue delete`: %v", err)
93 }
94
95 r := regexp.MustCompile(`Deleted issue OWNER/REPO#13 \(The title of the issue\)`)
96
97 if !r.MatchString(output.Stderr()) {
98 t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr())
99 }
100}
101
102func TestIssueDelete_confirm(t *testing.T) {
103 httpRegistry := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 10

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
GraphQLMutationFunction · 0.92
NewMockPrompterFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
runCommandFunction · 0.70

Tested by

no test coverage detected