mirror of
https://github.com/go-gitea/gitea.git
synced 2024-05-11 05:55:29 +00:00
fix: wrong pages number which includes private repository count. (#844)
This commit is contained in:
@ -1,11 +1,16 @@
|
||||
package models_test
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/markdown"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRepo(t *testing.T) {
|
||||
@ -68,3 +73,32 @@ func TestRepo(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetRepositoryCount(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
count, err1 := GetRepositoryCount(&User{ID: int64(10)})
|
||||
privateCount, err2 := GetPrivateRepositoryCount(&User{ID: int64(10)})
|
||||
publicCount, err3 := GetPublicRepositoryCount(&User{ID: int64(10)})
|
||||
assert.NoError(t, err1)
|
||||
assert.NoError(t, err2)
|
||||
assert.NoError(t, err3)
|
||||
assert.Equal(t, int64(3), count)
|
||||
assert.Equal(t, (privateCount + publicCount), count)
|
||||
}
|
||||
|
||||
func TestGetPublicRepositoryCount(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
count, err := GetPublicRepositoryCount(&User{ID: int64(10)})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, int64(1), count)
|
||||
}
|
||||
|
||||
func TestGetPrivateRepositoryCount(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
|
||||
count, err := GetPrivateRepositoryCount(&User{ID: int64(10)})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, int64(2), count)
|
||||
}
|
||||
|
Reference in New Issue
Block a user