Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scm/driver/bitbucket/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func (s *pullService) Merge(ctx context.Context, repo string, number int) (*scm.
}

func (s *pullService) Close(ctx context.Context, repo string, number int) (*scm.Response, error) {
return nil, scm.ErrNotSupported
path := fmt.Sprintf("2.0/repositories/%s/pullrequests/%d/decline", repo, number)
res, err := s.client.do(ctx, "POST", path, nil, nil)
return res, err
}

func (s *pullService) Create(ctx context.Context, repo string, input *scm.PullRequestInput) (*scm.PullRequest, *scm.Response, error) {
Expand Down
9 changes: 7 additions & 2 deletions scm/driver/bitbucket/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,15 @@ func TestPullMerge(t *testing.T) {
}

func TestPullClose(t *testing.T) {
defer gock.Off()
gock.New("https://api.bitbucket.org").
Post("2.0/repositories/atlassian/atlaskit/pullrequests/1/decline").
Reply(200).
Type("application/json")
client, _ := New("https://api.bitbucket.org")
_, err := client.PullRequests.Close(context.Background(), "atlassian/atlaskit", 1)
if err != scm.ErrNotSupported {
t.Errorf("Expect Not Supported error")
if err != nil {
t.Error(err)
}
}

Expand Down