diff --git a/command/issue.go b/command/issue.go index 0c2aae11b..b919cc843 100644 --- a/command/issue.go +++ b/command/issue.go @@ -544,6 +544,8 @@ func issueClose(cmd *cobra.Command, args []string) error { return fmt.Errorf("API call failed:%w", err) } + fmt.Fprintf(colorableErr(cmd), "%s closed issue #%d\n", utils.Green("✔"), issueNumber) + return nil } diff --git a/command/issue_test.go b/command/issue_test.go index 2185fc390..5ba66f3ea 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -686,19 +686,26 @@ func TestIssueClose(t *testing.T) { http := initFakeHTTP() http.StubRepoResponse("OWNER", "REPO") + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "hasIssuesEnabled": true, + "issue": { "id": "A-VERY-IMPORTANT-ID"} + } } } + `)) + jsonFile, _ := os.Open("../test/fixtures/issueClose.json") defer jsonFile.Close() http.StubResponse(200, jsonFile) - output, err := RunCommand(issueStatusCmd, "issue close 13") + output, err := RunCommand(issueCloseCmd, "issue close 13") if err != nil { t.Errorf("error running command `issue close`: %v", err) } - r := regexp.MustCompile(`WHATEVER!`) + r := regexp.MustCompile(`closed issue #13`) - if !r.MatchString(output.String()) { - t.Errorf("output did not match regexp /%s/\n> output\n%s\n", r, output) + if !r.MatchString(output.Stderr()) { + t.Errorf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) return } } diff --git a/test/fixtures/issueClose.json b/test/fixtures/issueClose.json new file mode 100644 index 000000000..047f1a6a8 --- /dev/null +++ b/test/fixtures/issueClose.json @@ -0,0 +1 @@ +{ "id": "hi" }