aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_test.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-06 23:18:36 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-06 23:18:36 +0800
commit71d35dae8cd33760b9be266a38d4f76b00ceb373 (patch)
treecf801d761f147e0fd73d56ca9e6956f5e3f116e1 /models/repo_test.go
parent76969a5671987d0aba5bfb72a7989aae71692254 (diff)
downloadgitea-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.go38
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)
+}