Close test now works

Co-Authored-By: Nate Smith <vilmibm@neongrid.space>
This commit is contained in:
Corey Johnson 2020-04-28 09:51:28 -07:00
parent a2f0cc6de7
commit 7ba6615919
3 changed files with 14 additions and 4 deletions

View file

@ -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
}

View file

@ -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
}
}

1
test/fixtures/issueClose.json vendored Normal file
View file

@ -0,0 +1 @@
{ "id": "hi" }