MCPcopy
hub / github.com/cli/cli / TestIssueReopen_withComment

Function TestIssueReopen_withComment

pkg/cmd/issue/reopen/reopen_test.go:155–196  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

153}
154
155func TestIssueReopen_withComment(t *testing.T) {
156 http := &httpmock.Registry{}
157 defer http.Verify(t)
158
159 http.Register(
160 httpmock.GraphQL(`query IssueByNumber\b`),
161 httpmock.StringResponse(`
162 { "data": { "repository": {
163 "hasIssuesEnabled": true,
164 "issue": { "id": "THE-ID", "number": 2, "state": "CLOSED", "title": "The title of the issue"}
165 } } }`),
166 )
167 http.Register(
168 httpmock.GraphQL(`mutation CommentCreate\b`),
169 httpmock.GraphQLMutation(`
170 { "data": { "addComment": { "commentEdge": { "node": {
171 "url": "https://github.com/OWNER/REPO/issues/123#issuecomment-456"
172 } } } } }`,
173 func(inputs map[string]interface{}) {
174 assert.Equal(t, "THE-ID", inputs["subjectId"])
175 assert.Equal(t, "reopening comment", inputs["body"])
176 }),
177 )
178 http.Register(
179 httpmock.GraphQL(`mutation IssueReopen\b`),
180 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
181 func(inputs map[string]interface{}) {
182 assert.Equal(t, inputs["issueId"], "THE-ID")
183 }),
184 )
185
186 output, err := runCommand(http, true, "2 --comment 'reopening comment'")
187 if err != nil {
188 t.Fatalf("error running command `issue reopen`: %v", err)
189 }
190
191 r := regexp.MustCompile(`Reopened issue OWNER/REPO#2 \(The title of the issue\)`)
192
193 if !r.MatchString(output.Stderr()) {
194 t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr())
195 }
196}

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected