Remove opts from ListPullReviewComments (#411)

Remove ListPullReviewsCommentsOptions as ListPullReviewComments has no options

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/411
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Gary Kim <gary@garykim.dev>
This commit is contained in:
6543 2020-09-07 03:00:26 +00:00 committed by techknowlogick
parent 595ceb32ff
commit 88552ee13a
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
}