MCPcopy Index your code
hub / github.com/cli/cli / TestIssueReopen

Function TestIssueReopen

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

Source from the content-addressed store, hash-verified

63}
64
65func TestIssueReopen(t *testing.T) {
66 http := &httpmock.Registry{}
67 defer http.Verify(t)
68
69 http.Register(
70 httpmock.GraphQL(`query IssueByNumber\b`),
71 httpmock.StringResponse(`
72 { "data": { "repository": {
73 "hasIssuesEnabled": true,
74 "issue": { "id": "THE-ID", "number": 2, "state": "CLOSED", "title": "The title of the issue"}
75 } } }`),
76 )
77 http.Register(
78 httpmock.GraphQL(`mutation IssueReopen\b`),
79 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
80 func(inputs map[string]interface{}) {
81 assert.Equal(t, inputs["issueId"], "THE-ID")
82 }),
83 )
84
85 output, err := runCommand(http, true, "2")
86 if err != nil {
87 t.Fatalf("error running command `issue reopen`: %v", err)
88 }
89
90 r := regexp.MustCompile(`Reopened issue OWNER/REPO#2 \(The title of the issue\)`)
91
92 if !r.MatchString(output.Stderr()) {
93 t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr())
94 }
95}
96
97func TestIssueReopen_alreadyOpen(t *testing.T) {
98 http := &httpmock.Registry{}

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