From 66abe9e62e138d01c107de2f40c3d2373dc3c3b4 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 30 Apr 2020 11:24:27 -0700 Subject: [PATCH] Add pr close test --- command/pr_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/command/pr_test.go b/command/pr_test.go index ba0989645..a133e04f9 100644 --- a/command/pr_test.go +++ b/command/pr_test.go @@ -800,3 +800,28 @@ func TestPrStateTitleWithColor(t *testing.T) { }) } } + +func TestPrClose(t *testing.T) { + initBlankContext("", "OWNER/REPO", "master") + http := initFakeHTTP() + http.StubRepoResponse("OWNER", "REPO") + + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "pullRequest": { "number": 96 } + } } } + `)) + + http.StubResponse(200, bytes.NewBufferString(`{"id": "THE-ID"}`)) + + output, err := RunCommand(prCloseCmd, "pr close 96") + if err != nil { + t.Fatalf("error running command `pr close`: %v", err) + } + + r := regexp.MustCompile(`Closed pull request #96`) + + if !r.MatchString(output.Stderr()) { + t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) + } +}