@ -13,6 +13,7 @@ import (
"testing"
"testing"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
api "code.gitea.io/gitea/modules/structs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
@ -57,6 +58,12 @@ func TestAPISearchRepo(t *testing.T) {
user4 := models . AssertExistsAndLoadBean ( t , & models . User { ID : 20 } ) . ( * models . User )
user4 := models . AssertExistsAndLoadBean ( t , & models . User { ID : 20 } ) . ( * models . User )
orgUser := models . AssertExistsAndLoadBean ( t , & models . User { ID : 17 } ) . ( * models . User )
orgUser := models . AssertExistsAndLoadBean ( t , & models . User { ID : 17 } ) . ( * models . User )
oldAPIDefaultNum := setting . API . DefaultPagingNum
defer func ( ) {
setting . API . DefaultPagingNum = oldAPIDefaultNum
} ( )
setting . API . DefaultPagingNum = 10
// Map of expected results, where key is user for login
// Map of expected results, where key is user for login
type expectedResults map [ * models . User ] struct {
type expectedResults map [ * models . User ] struct {
count int
count int
@ -79,7 +86,7 @@ func TestAPISearchRepo(t *testing.T) {
user : { count : 10 } ,
user : { count : 10 } ,
user2 : { count : 10 } } ,
user2 : { count : 10 } } ,
} ,
} ,
{ name : "RepositoriesDefaultMax10 " , requestURL : "/api/v1/repos/search?default&private=false" , expectedResults : expectedResults {
{ name : "RepositoriesDefault" , requestURL : "/api/v1/repos/search?default&private=false" , expectedResults : expectedResults {
nil : { count : 10 } ,
nil : { count : 10 } ,
user : { count : 10 } ,
user : { count : 10 } ,
user2 : { count : 10 } } ,
user2 : { count : 10 } } ,