diff options
author | 6543 <6543@obermui.de> | 2020-11-23 21:49:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 20:49:36 +0000 |
commit | f88a2eae9777e0be612647bc17227c1ca13616ba (patch) | |
tree | 78aad7908e3fa61e674610cb24c7f4d1b8ad9bc2 /integrations/api_issue_test.go | |
parent | 78204a7a71eedbc099aff51abd88cb16f60d50a8 (diff) | |
download | gitea-f88a2eae9777e0be612647bc17227c1ca13616ba.tar.gz gitea-f88a2eae9777e0be612647bc17227c1ca13616ba.zip |
[API] Add more filters to issues search (#13514)
* Add time filter for issue search
* Add limit option for paggination
* Add Filter for: Created by User, Assigned to User, Mentioning User
* update swagger
* Add Tests for limit, before & since
Diffstat (limited to 'integrations/api_issue_test.go')
-rw-r--r-- | integrations/api_issue_test.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/integrations/api_issue_test.go b/integrations/api_issue_test.go index 9311d50c5c..81e5c44873 100644 --- a/integrations/api_issue_test.go +++ b/integrations/api_issue_test.go @@ -9,6 +9,7 @@ import ( "net/http" "net/url" "testing" + "time" "code.gitea.io/gitea/models" api "code.gitea.io/gitea/modules/structs" @@ -152,17 +153,27 @@ func TestAPISearchIssues(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) var apiIssues []*api.Issue DecodeJSON(t, resp, &apiIssues) - assert.Len(t, apiIssues, 10) - query := url.Values{} - query.Add("token", token) + query := url.Values{"token": {token}} link.RawQuery = query.Encode() req = NewRequest(t, "GET", link.String()) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiIssues) assert.Len(t, apiIssues, 10) + since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801 + before := time.Unix(999307200, 0).Format(time.RFC3339) + query.Add("since", since) + query.Add("before", before) + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()) + resp = session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 8) + query.Del("since") + query.Del("before") + query.Add("state", "closed") link.RawQuery = query.Encode() req = NewRequest(t, "GET", link.String()) @@ -175,14 +186,22 @@ func TestAPISearchIssues(t *testing.T) { req = NewRequest(t, "GET", link.String()) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiIssues) + assert.EqualValues(t, "12", resp.Header().Get("X-Total-Count")) assert.Len(t, apiIssues, 10) //there are more but 10 is page item limit - query.Add("page", "2") + query.Add("limit", "20") link.RawQuery = query.Encode() req = NewRequest(t, "GET", link.String()) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiIssues) - assert.Len(t, apiIssues, 2) + assert.Len(t, apiIssues, 12) + + query = url.Values{"assigned": {"true"}, "state": {"all"}} + link.RawQuery = query.Encode() + req = NewRequest(t, "GET", link.String()) + resp = session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &apiIssues) + assert.Len(t, apiIssues, 1) } func TestAPISearchIssuesWithLabels(t *testing.T) { |