(t *testing.T)
| 153 | } |
| 154 | |
| 155 | func 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 | } |
nothing calls this directly
no test coverage detected