diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-02-06 23:18:36 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-06 23:18:36 +0800 |
commit | 71d35dae8cd33760b9be266a38d4f76b00ceb373 (patch) | |
tree | cf801d761f147e0fd73d56ca9e6956f5e3f116e1 /models/repo_test.go | |
parent | 76969a5671987d0aba5bfb72a7989aae71692254 (diff) | |
download | gitea-71d35dae8cd33760b9be266a38d4f76b00ceb373.tar.gz gitea-71d35dae8cd33760b9be266a38d4f76b00ceb373.zip |
fix: wrong pages number which includes private repository count. (#844)
Diffstat (limited to 'models/repo_test.go')
-rw-r--r-- | models/repo_test.go | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/models/repo_test.go b/models/repo_test.go index 42bde62b46..499c8c83eb 100644 --- a/models/repo_test.go +++ b/models/repo_test.go @@ -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) +} |