diff options
author | qwerty287 <80460567+qwerty287@users.noreply.github.com> | 2022-01-01 15:12:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-01 22:12:25 +0800 |
commit | 7db2f110adbd020e70c56497306cfbda8806d109 (patch) | |
tree | 2f5372cc0f1ffde0abb2899b8e262ee33fb84601 /integrations | |
parent | 549fd03c0e9aa19850c8271cbd7cd62bbc884b34 (diff) | |
download | gitea-7db2f110adbd020e70c56497306cfbda8806d109.tar.gz gitea-7db2f110adbd020e70c56497306cfbda8806d109.zip |
Add API to get issue/pull comments and events (timeline) (#17403)
* Add API to get issue/pull comments and events (timeline)
Adds an API to get both comments and events in one endpoint with all required data.
Closes go-gitea/gitea#13250
* Fix swagger
* Don't show code comments (use review api instead)
* fmt
* Fix comment
* Time -> TrackedTime
* Use var directly
* Add logger
* Fix lint
* Fix test
* Add comments
* fmt
* [test] get issue directly by ID
* Update test
* Add description for changed refs
* Fix build issues + lint
* Fix build
* Use string enums
* Update swagger
* Support `page` and `limit` params
* fmt + swagger
* Use global slices
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/api_comment_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/integrations/api_comment_test.go b/integrations/api_comment_test.go index 0c3ac2ae5b..4c4c6308ee 100644 --- a/integrations/api_comment_test.go +++ b/integrations/api_comment_test.go @@ -180,3 +180,25 @@ func TestAPIDeleteComment(t *testing.T) { unittest.AssertNotExistsBean(t, &models.Comment{ID: comment.ID}) } + +func TestAPIListIssueTimeline(t *testing.T) { + defer prepareTestEnv(t)() + + // load comment + issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: 1}).(*models.Issue) + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID}).(*repo_model.Repository) + repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User) + + // make request + session := loginUser(t, repoOwner.Name) + req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/%d/timeline", + repoOwner.Name, repo.Name, issue.Index) + resp := session.MakeRequest(t, req, http.StatusOK) + + // check if lens of list returned by API and + // lists extracted directly from DB are the same + var comments []*api.TimelineComment + DecodeJSON(t, resp, &comments) + expectedCount := unittest.GetCount(t, &models.Comment{IssueID: issue.ID}) + assert.EqualValues(t, expectedCount, len(comments)) +} |