Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new pull request review API #497

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
354caf4
Add 'list all reviews' endpoint from new pull request review API
sahildua2305 Dec 16, 2016
36c6f8c
Add GetReview and ListReviewComments methods to PullRequest
sahildua2305 Dec 17, 2016
a8392c4
Update GetReview and ListReviewComments to include repo param
sahildua2305 Dec 17, 2016
1ce3518
Add CreateReview method to PullRequest service
sahildua2305 Dec 18, 2016
5182678
Modify CreateReview to add PullRequestReviewRequest struct
sahildua2305 Dec 18, 2016
178c4ed
Add SubmitReview method to PullRequest service
sahildua2305 Dec 18, 2016
a8df51b
Fix minor typos related to SubmitReview method
sahildua2305 Dec 18, 2016
cd49c5c
Add DismissReview method to PullRequest service
sahildua2305 Dec 18, 2016
167e217
Fix minor formatting issue with gofmt
sahildua2305 Dec 18, 2016
99df209
Create new struct PullRequestReveiwDismissalRequest
sahildua2305 Dec 21, 2016
c60f5b3
Rename 'id' param to 'reviewID' to make it more verbose
sahildua2305 Dec 21, 2016
cd5b665
Fix minor issue with comment for state
sahildua2305 Dec 21, 2016
109ded2
Add String methods and their tests for all new types
sahildua2305 Dec 23, 2016
2bd08d4
Add unit tests for invalid cases
sahildua2305 Dec 23, 2016
87729c2
Complete tests for invalid cases for all 6 new endpoints
sahildua2305 Dec 29, 2016
a176b03
Replace PullRequestReviewComment with PullRequestComment
sahildua2305 Dec 29, 2016
e3b5e69
Remove misleading comment from PullRequestReview
sahildua2305 Jan 5, 2017
a1bf055
Add a note and todo about known issue with SubmitReview
sahildua2305 Jan 6, 2017
91cc8ae
Add DeletePendingReview endpoint
sahildua2305 Jan 31, 2017
bfda8ba
Make minor changes as suggested by gmlewis
sahildua2305 Feb 1, 2017
36dbd69
Doc: Add comment about known error format issue
sahildua2305 Feb 2, 2017
0c0faa4
Fix typo and mention issue link as comment
sahildua2305 Feb 2, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions github/pulls_reviews.go
Expand Up @@ -103,6 +103,29 @@ func (s *PullRequestsService) GetReview(owner string, repo string, number int, r
return review, resp, err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return review, resp, nil

}

// DeletePendingReview deletes the specified pull request pending review.
//
// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review
func (s *PullRequestsService) DeletePendingReview(owner string, repo string, number int, reviewID int) (*PullRequestReview, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 馃憤

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(owner, repo string, number, reviewID int)

u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID)

req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)

review := new(PullRequestReview)
resp, err := s.client.Do(req, review)
if err != nil {
return nil, resp, err
}

return review, resp, err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return review, resp, nil

}

// ListReviewComments lists all the comments for the specified review.
//
// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments
Expand Down
26 changes: 26 additions & 0 deletions github/pulls_reviews_test.go
Expand Up @@ -68,6 +68,32 @@ func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) {
testURLParseError(t, err)
}

func TestPullRequestsService_DeletePendingReview(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
fmt.Fprint(w, `{"id":1}`)
})

review, _, err := client.PullRequests.DeletePendingReview("o", "r", 1, 1)
if err != nil {
t.Errorf("PullRequests.DeletePendingReview returned error: %v", err)
}

want := &PullRequestReview{ID: Int(1)}
if !reflect.DeepEqual(review, want) {
t.Errorf("PullRequests.DeletePendingReview returned %+v, want %+v", review, want)
}
}

func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) {
_, _, err := client.PullRequests.DeletePendingReview("%", "r", 1, 1)
testURLParseError(t, err)
}

func TestPullRequestsService_ListReviewComments(t *testing.T) {
setup()
defer teardown()
Expand Down