From b8ff489bb5766c8c27bcf11247a94f3f2c41d3e8 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 1 May 2020 12:07:30 -0700 Subject: [PATCH] Add already open test --- command/pr_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/command/pr_test.go b/command/pr_test.go index af876bf0a..8585dd83f 100644 --- a/command/pr_test.go +++ b/command/pr_test.go @@ -874,3 +874,28 @@ func TestPRReopen(t *testing.T) { t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) } } + +func TestPRReopen_alreadyOpen(t *testing.T) { + initBlankContext("", "OWNER/REPO", "master") + http := initFakeHTTP() + http.StubRepoResponse("OWNER", "REPO") + + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "pullRequest": { "number": 666, "closed": false} + } } } + `)) + + http.StubResponse(200, bytes.NewBufferString(`{"id": "THE-ID"}`)) + + output, err := RunCommand(prReopenCmd, "pr reopen 666") + if err != nil { + t.Fatalf("error running command `pr reopen`: %v", err) + } + + r := regexp.MustCompile(`Pull request #666 is already open`) + + if !r.MatchString(output.Stderr()) { + t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) + } +}