From 7df1b992db85e003e0ba694f8a49310e0479a46f Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 29 Apr 2020 13:57:53 -0700 Subject: [PATCH] Add "already open" test --- command/issue.go | 2 +- command/issue_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/command/issue.go b/command/issue.go index 68491764b..0271c4e4c 100644 --- a/command/issue.go +++ b/command/issue.go @@ -589,7 +589,7 @@ func issueReopen(cmd *cobra.Command, args []string) error { } if !issue.Closed { - fmt.Fprintf(colorableErr(cmd), "%s Issue #%d was already open\n", utils.Yellow("!"), issue.Number) + fmt.Fprintf(colorableErr(cmd), "%s Issue #%d is already open\n", utils.Yellow("!"), issue.Number) return nil } diff --git a/command/issue_test.go b/command/issue_test.go index 05d1049b5..eee7218c3 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -779,3 +779,29 @@ func TestIssueReopen(t *testing.T) { t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) } } + +func TestIssueReopen_alreadyOpen(t *testing.T) { + initBlankContext("", "OWNER/REPO", "master") + http := initFakeHTTP() + http.StubRepoResponse("OWNER", "REPO") + + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "hasIssuesEnabled": true, + "issue": { "number": 2, "closed": false} + } } } + `)) + + http.StubResponse(200, bytes.NewBufferString(`{"id": "THE-ID"}`)) + + output, err := RunCommand(issueReopenCmd, "issue reopen 2") + if err != nil { + t.Fatalf("error running command `issue reopen`: %v", err) + } + + r := regexp.MustCompile(`#2 is already open`) + + if !r.MatchString(output.Stderr()) { + t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) + } +}