Remove opts from ListPullReviewComments #411

Merged
techknowlogick merged 5 commits from 6543/go-sdk:GetPullReviewComments-has-no-opts into master 2020-09-07 03:01:32 +00:00
2 changed files with 8 additions and 14 deletions

View File

@ -154,21 +154,13 @@ func (c *Client) GetPullReview(owner, repo string, index, id int64) (*PullReview
return r, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d/reviews/%d", owner, repo, index, id), jsonHeader, nil, &r)
}
// ListPullReviewsCommentsOptions options for listing PullReviewsComments
type ListPullReviewsCommentsOptions struct {
ListOptions
}
// ListPullReviewComments lists all comments of a pull request review
func (c *Client) ListPullReviewComments(owner, repo string, index, id int64, opt ListPullReviewsCommentsOptions) ([]*PullReviewComment, error) {
func (c *Client) ListPullReviewComments(owner, repo string, index, id int64) ([]*PullReviewComment, error) {
if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil {
return nil, err
}
opt.setDefaults()
rcl := make([]*PullReviewComment, 0, opt.PageSize)
rcl := make([]*PullReviewComment, 0, 4)
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/pulls/%d/reviews/%d/comments", owner, repo, index, id))
link.RawQuery = opt.ListOptions.getURLQuery().Encode()
return rcl, c.getParsedResponse("GET", link.String(), jsonHeader, nil, &rcl)
}

View File

@ -120,11 +120,11 @@ func TestPullReview(t *testing.T) {
assert.EqualValues(t, ReviewStateRequestChanges, r.State)
// ListPullReviewComments
rcl, err := c.ListPullReviewComments(repo.Owner.UserName, repo.Name, pull.Index, r.ID, ListPullReviewsCommentsOptions{})
rcl, err := c.ListPullReviewComments(repo.Owner.UserName, repo.Name, pull.Index, r.ID)
assert.NoError(t, err)
assert.EqualValues(t, r.CodeCommentsCount, len(rcl))
for _, rc := range rcl {
//assert.EqualValues(t, pull.HTMLURL, rc.HTMLPullURL) https://github.com/go-gitea/gitea/issues/11499
assert.EqualValues(t, pull.HTMLURL, rc.HTMLPullURL)
if rc.LineNum == 3 {
assert.EqualValues(t, "hehe and here it is", rc.Body)
} else {
@ -143,9 +143,10 @@ func preparePullReviewTest(t *testing.T, c *Client, repoName string) (*Repositor
pullSubmitter := createTestUser(t, "pull_submitter", c)
write := AccessModeWrite
c.AddCollaborator(repo.Owner.UserName, repo.Name, pullSubmitter.UserName, AddCollaboratorOption{
err = c.AddCollaborator(repo.Owner.UserName, repo.Name, pullSubmitter.UserName, AddCollaboratorOption{
Permission: &write,
})
assert.NoError(t, err)
c.SetSudo("pull_submitter")
@ -174,9 +175,10 @@ func preparePullReviewTest(t *testing.T, c *Client, repoName string) (*Repositor
reviewer := createTestUser(t, "pull_reviewer", c)
admin := AccessModeAdmin
c.AddCollaborator(repo.Owner.UserName, repo.Name, pullSubmitter.UserName, AddCollaboratorOption{
err = c.AddCollaborator(repo.Owner.UserName, repo.Name, pullSubmitter.UserName, AddCollaboratorOption{
Permission: &admin,
})
assert.NoError(t, err)
return repo, pull, pullSubmitter, reviewer, pull.Poster.ID == pullSubmitter.ID
}