summaryrefslogtreecommitdiffstats
path: root/integrations/api_issue_test.go
diff options
context:
space:
mode:
authorNorwin <noerw@users.noreply.github.com>2022-08-06 12:43:40 +0200
committerGitHub <noreply@github.com>2022-08-06 18:43:40 +0800
commit279e4e235cd28b570e2947cc8c397280e9250440 (patch)
treecb3295726a2b4c34d24b95f93b30756020c5395d /integrations/api_issue_test.go
parent61aafb9c7d367e4cc369c4d79eb58f278edb0ce8 (diff)
downloadgitea-279e4e235cd28b570e2947cc8c397280e9250440.tar.gz
gitea-279e4e235cd28b570e2947cc8c397280e9250440.zip
Increase default item listing size `ISSUE_PAGING_NUM` to 20 (#20547)
* increase default page sizes to 20 * adjust docs to reflect that the setting is used all over the place * fix tests Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'integrations/api_issue_test.go')
-rw-r--r--integrations/api_issue_test.go46
1 files changed, 24 insertions, 22 deletions
diff --git a/integrations/api_issue_test.go b/integrations/api_issue_test.go
index 5c802e8d20..bb4e2f0c72 100644
--- a/integrations/api_issue_test.go
+++ b/integrations/api_issue_test.go
@@ -16,6 +16,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"github.com/stretchr/testify/assert"
@@ -171,19 +172,21 @@ func TestAPISearchIssues(t *testing.T) {
token := getUserToken(t, "user2")
+ // as this API was used in the frontend, it uses UI page size
+ expectedIssueCount := 15 // from the fixtures
+ if expectedIssueCount > setting.UI.IssuePagingNum {
+ expectedIssueCount = setting.UI.IssuePagingNum
+ }
+
link, _ := url.Parse("/api/v1/repos/issues/search")
- req := NewRequest(t, "GET", link.String()+"?token="+token)
- resp := MakeRequest(t, req, http.StatusOK)
+ query := url.Values{"token": {getUserToken(t, "user1")}}
var apiIssues []*api.Issue
- DecodeJSON(t, resp, &apiIssues)
- assert.Len(t, apiIssues, 10)
- query := url.Values{"token": {token}}
link.RawQuery = query.Encode()
- req = NewRequest(t, "GET", link.String())
- resp = MakeRequest(t, req, http.StatusOK)
+ req := NewRequest(t, "GET", link.String())
+ resp := MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiIssues)
- assert.Len(t, apiIssues, 10)
+ assert.Len(t, apiIssues, expectedIssueCount)
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
before := time.Unix(999307200, 0).Format(time.RFC3339)
@@ -211,14 +214,15 @@ func TestAPISearchIssues(t *testing.T) {
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiIssues)
assert.EqualValues(t, "17", resp.Header().Get("X-Total-Count"))
- assert.Len(t, apiIssues, 10) // there are more but 10 is page item limit
+ assert.Len(t, apiIssues, 17)
- query.Add("limit", "20")
+ query.Add("limit", "10")
link.RawQuery = query.Encode()
req = NewRequest(t, "GET", link.String())
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiIssues)
- assert.Len(t, apiIssues, 17)
+ assert.EqualValues(t, "17", resp.Header().Get("X-Total-Count"))
+ assert.Len(t, apiIssues, 10)
query = url.Values{"assigned": {"true"}, "state": {"all"}, "token": {token}}
link.RawQuery = query.Encode()
@@ -266,23 +270,21 @@ func TestAPISearchIssues(t *testing.T) {
func TestAPISearchIssuesWithLabels(t *testing.T) {
defer prepareTestEnv(t)()
- token := getUserToken(t, "user1")
+ // as this API was used in the frontend, it uses UI page size
+ expectedIssueCount := 15 // from the fixtures
+ if expectedIssueCount > setting.UI.IssuePagingNum {
+ expectedIssueCount = setting.UI.IssuePagingNum
+ }
link, _ := url.Parse("/api/v1/repos/issues/search")
- req := NewRequest(t, "GET", link.String()+"?token="+token)
- resp := MakeRequest(t, req, http.StatusOK)
+ query := url.Values{"token": {getUserToken(t, "user1")}}
var apiIssues []*api.Issue
- DecodeJSON(t, resp, &apiIssues)
-
- assert.Len(t, apiIssues, 10)
- query := url.Values{}
- query.Add("token", token)
link.RawQuery = query.Encode()
- req = NewRequest(t, "GET", link.String())
- resp = MakeRequest(t, req, http.StatusOK)
+ req := NewRequest(t, "GET", link.String())
+ resp := MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiIssues)
- assert.Len(t, apiIssues, 10)
+ assert.Len(t, apiIssues, expectedIssueCount)
query.Add("labels", "label1")
link.RawQuery = query.Encode()