(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func 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 | |
| 102 | func TestIssueDelete_confirm(t *testing.T) { |
| 103 | httpRegistry := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected