From 88552ee13a72a69d54f8c056b24b55b2310186b3 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Mon, 7 Sep 2020 03:00:26 +0000 Subject: [PATCH] Remove opts from ListPullReviewComments (#411) Remove ListPullReviewsCommentsOptions as ListPullReviewComments has no options Co-authored-by: techknowlogick Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/411 Reviewed-by: Andrew Thornton Reviewed-by: Gary Kim --- gitea/pull_review.go | 12 ++---------- gitea/pull_review_test.go | 10 ++++++---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/gitea/pull_review.go b/gitea/pull_review.go index 8e5a5e8..169ac1a 100644 --- a/gitea/pull_review.go +++ b/gitea/pull_review.go @@ -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) } diff --git a/gitea/pull_review_test.go b/gitea/pull_review_test.go index 19e2231..433cc37 100644 --- a/gitea/pull_review_test.go +++ b/gitea/pull_review_test.go @@ -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 }