[GITEA] GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments/{comment}

Refs: https://codeberg.org/forgejo/forgejo/issues/2109
(cherry picked from commit 69fcf26dee0e6886460b533575f29e5b818bbc17)
(cherry picked from commit 1296f4d115e1441657cfdac53807743a8b7ca6ba)
(cherry picked from commit 119d10d9e277e7f738eba8087ce6cf4905e183e8)
(cherry picked from commit eb5b55b1b7438a40da2462401a95dfdff493b20d)
This commit is contained in:
Earl Warren 2024-01-11 12:32:18 +01:00
parent e658a6a9cd
commit bd1cea3f82
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 141 additions and 13 deletions

View file

@ -68,6 +68,7 @@ func TestAPIPullReviewCreateComment(t *testing.T) {
}
newCommentBody := "first new line"
var reviewComment api.PullReviewComment
{
req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/pulls/%d/reviews/%d/comments", repo.FullName(), pullIssue.Index, review.ID), &api.CreatePullReviewCommentOptions{
@ -76,24 +77,22 @@ func TestAPIPullReviewCreateComment(t *testing.T) {
OldLineNum: reviewLine,
}).AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var reviewComment *api.PullReviewComment
DecodeJSON(t, resp, &reviewComment)
assert.EqualValues(t, review.ID, reviewComment.ReviewID)
assert.EqualValues(t, newCommentBody, reviewComment.Body)
assert.EqualValues(t, reviewLine, reviewComment.OldLineNum)
assert.EqualValues(t, 0, reviewComment.LineNum)
assert.EqualValues(t, path, reviewComment.Path)
}
{
req := NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/pulls/%d/reviews/%d/comments", repo.FullName(), pullIssue.Index, review.ID).
req := NewRequestf(t, http.MethodGet, "/api/v1/repos/%s/pulls/%d/reviews/%d/comments/%d", repo.FullName(), pullIssue.Index, review.ID, reviewComment.ID).
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var reviewComments []*api.PullReviewComment
DecodeJSON(t, resp, &reviewComments)
assert.Len(t, reviewComments, 2)
assert.EqualValues(t, existingCommentBody, reviewComments[0].Body)
assert.EqualValues(t, reviewComments[0].OldLineNum, reviewComments[1].OldLineNum)
assert.EqualValues(t, reviewComments[0].LineNum, reviewComments[1].LineNum)
assert.EqualValues(t, newCommentBody, reviewComments[1].Body)
assert.EqualValues(t, path, reviewComments[1].Path)
var comment api.PullReviewComment
DecodeJSON(t, resp, &comment)
assert.EqualValues(t, reviewComment, comment)
}
{