aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_comment_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-01-08 08:00:59 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2020-01-08 15:00:59 +0800
commite88d67b774ae615208b25133c299f2d50b3a018b (patch)
tree4471be8b873a81f2ce7a7c951e9fcf5ab4518a2b /integrations/api_comment_test.go
parentc884735740ddbf6c950b44964b7ef7c77c4a0325 (diff)
downloadgitea-e88d67b774ae615208b25133c299f2d50b3a018b.tar.gz
gitea-e88d67b774ae615208b25133c299f2d50b3a018b.zip
[API] add comments endpoint for single comment (#9494)
* add GET /repos/{owner}/{repo}/issues/comments/{id} and complete error list for swagger in other func * add repo check
Diffstat (limited to 'integrations/api_comment_test.go')
-rw-r--r--integrations/api_comment_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/integrations/api_comment_test.go b/integrations/api_comment_test.go
index 0716c5d859..d21f56aaf8 100644
--- a/integrations/api_comment_test.go
+++ b/integrations/api_comment_test.go
@@ -83,6 +83,33 @@ func TestAPICreateComment(t *testing.T) {
models.AssertExistsAndLoadBean(t, &models.Comment{ID: updatedComment.ID, IssueID: issue.ID, Content: commentBody})
}
+func TestAPIGetComment(t *testing.T) {
+ defer prepareTestEnv(t)()
+
+ comment := models.AssertExistsAndLoadBean(t, &models.Comment{ID: 2}).(*models.Comment)
+ assert.NoError(t, comment.LoadIssue())
+ repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: comment.Issue.RepoID}).(*models.Repository)
+ repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
+
+ session := loginUser(t, repoOwner.Name)
+ token := getTokenForLoggedInUser(t, session)
+ req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d", repoOwner.Name, repo.Name, comment.ID)
+ resp := session.MakeRequest(t, req, http.StatusOK)
+ req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d?token=%s", repoOwner.Name, repo.Name, comment.ID, token)
+ resp = session.MakeRequest(t, req, http.StatusOK)
+
+ var apiComment api.Comment
+ DecodeJSON(t, resp, &apiComment)
+
+ assert.NoError(t, comment.LoadPoster())
+ expect := comment.APIFormat()
+
+ assert.Equal(t, expect.ID, apiComment.ID)
+ assert.Equal(t, expect.Poster.FullName, apiComment.Poster.FullName)
+ assert.Equal(t, expect.Body, apiComment.Body)
+ assert.Equal(t, expect.Created.Unix(), apiComment.Created.Unix())
+}
+
func TestAPIEditComment(t *testing.T) {
defer prepareTestEnv(t)()
const newCommentBody = "This is the new comment body"