diff options
author | 6543 <6543@obermui.de> | 2020-01-13 17:02:24 +0100 |
---|---|---|
committer | Antoine GIRARD <sapk@users.noreply.github.com> | 2020-01-13 17:02:24 +0100 |
commit | 0b3aaa61964faa85b8008b04487388cc362ab436 (patch) | |
tree | cc6a3eda4780b7c8aa2d9e108a8a0ec393fbbb83 /integrations | |
parent | b7ffc6a096bdb231d95ecbb5db878e3d8b2b63c9 (diff) | |
download | gitea-0b3aaa61964faa85b8008b04487388cc362ab436.tar.gz gitea-0b3aaa61964faa85b8008b04487388cc362ab436.zip |
[API] Add "before" query to ListIssueComments and ListRepoIssue… (#9685)
* add "before" query to ListIssueComments and ListRepoIssueComments
* Add TEST
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/api_comment_test.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/integrations/api_comment_test.go b/integrations/api_comment_test.go index d21f56aaf8..2c754272e5 100644 --- a/integrations/api_comment_test.go +++ b/integrations/api_comment_test.go @@ -7,6 +7,7 @@ package integrations import ( "fmt" "net/http" + "net/url" "testing" "code.gitea.io/gitea/models" @@ -25,18 +26,40 @@ func TestAPIListRepoComments(t *testing.T) { repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) session := loginUser(t, repoOwner.Name) - req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments", - repoOwner.Name, repo.Name) + link, _ := url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments", repoOwner.Name, repo.Name)) + req := NewRequest(t, "GET", link.String()) resp := session.MakeRequest(t, req, http.StatusOK) var apiComments []*api.Comment DecodeJSON(t, resp, &apiComments) + assert.Len(t, apiComments, 2) for _, apiComment := range apiComments { c := &models.Comment{ID: apiComment.ID} models.AssertExistsAndLoadBean(t, c, models.Cond("type = ?", models.CommentTypeComment)) models.AssertExistsAndLoadBean(t, &models.Issue{ID: c.IssueID, RepoID: repo.ID}) } + + //test before and since filters + query := url.Values{} + before := "2000-01-01T00:00:11+00:00" //unix: 946684811 + since := "2000-01-01T00:00:12+00:00" //unix: 946684812 + query.Add("before", before) + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()) + resp = session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiComments) + assert.Len(t, apiComments, 1) + assert.EqualValues(t, 2, apiComments[0].ID) + + query.Del("before") + query.Add("since", since) + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()) + resp = session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiComments) + assert.Len(t, apiComments, 1) + assert.EqualValues(t, 3, apiComments[0].ID) } func TestAPIListIssueComments(t *testing.T) { |