From c78c30b32fc73703e3ad9abed02c655f24cc646e Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 29 Apr 2020 11:33:16 -0700 Subject: [PATCH] Add already closed test --- command/issue_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/command/issue_test.go b/command/issue_test.go index cddab4efa..bddef2e30 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -707,6 +707,32 @@ func TestIssueClose(t *testing.T) { } } +func TestIssueClose_alreadyClosed(t *testing.T) { + initBlankContext("", "OWNER/REPO", "master") + http := initFakeHTTP() + http.StubRepoResponse("OWNER", "REPO") + + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "hasIssuesEnabled": true, + "issue": { "number": 13, "closed": true} + } } } + `)) + + http.StubResponse(200, bytes.NewBufferString(`{"id": "THE-ID"}`)) + + output, err := RunCommand(issueCloseCmd, "issue close 13") + if err != nil { + t.Fatalf("error running command `issue close`: %v", err) + } + + r := regexp.MustCompile(`#13 is already closed`) + + if !r.MatchString(output.Stderr()) { + t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) + } +} + func TestIssueClose_issuesDisabled(t *testing.T) { initBlankContext("", "OWNER/REPO", "master") http := initFakeHTTP()