summaryrefslogtreecommitdiffstats
path: root/models/repo_test.go
diff options
context:
space:
mode:
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)
+}