summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-28 17:58:50 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-28 17:58:50 +0800
commite83c8afc56c028bddba5074fb945cb0b7c45d32b (patch)
treed19582529dfd70ca46b6c0ba73e1d597ec5d70cc
parentc2eef171ff98d0ead2477296b7ae4e05b602da88 (diff)
downloadgitea-e83c8afc56c028bddba5074fb945cb0b7c45d32b.tar.gz
gitea-e83c8afc56c028bddba5074fb945cb0b7c45d32b.zip
refactor: move SearchRepositoryByName testing. (#1083)
-rw-r--r--models/repo_list_test.go63
-rw-r--r--models/repo_test.go52
2 files changed, 63 insertions, 52 deletions
diff --git a/models/repo_list_test.go b/models/repo_list_test.go
new file mode 100644
index 0000000000..1fbfa935e9
--- /dev/null
+++ b/models/repo_list_test.go
@@ -0,0 +1,63 @@
+// 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"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestSearchRepositoryByName(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ // test search public repository on explore page
+ repos, count, err := SearchRepositoryByName(&SearchRepoOptions{
+ Keyword: "repo_12",
+ Page: 1,
+ PageSize: 10,
+ Searcher: nil,
+ })
+
+ assert.NotNil(t, repos)
+ assert.NoError(t, err)
+ assert.Equal(t, "test_repo_12", repos[0].Name)
+ assert.Equal(t, int64(1), count)
+
+ repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
+ Keyword: "test_repo",
+ Page: 1,
+ PageSize: 10,
+ Searcher: nil,
+ })
+
+ assert.NotNil(t, repos)
+ assert.NoError(t, err)
+ assert.Equal(t, int64(2), count)
+
+ // test search private repository on explore page
+ repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
+ Keyword: "repo_13",
+ Page: 1,
+ PageSize: 10,
+ Searcher: &User{ID: 14},
+ })
+
+ assert.NotNil(t, repos)
+ assert.NoError(t, err)
+ assert.Equal(t, "test_repo_13", repos[0].Name)
+ assert.Equal(t, int64(1), count)
+
+ repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
+ Keyword: "test_repo",
+ Page: 1,
+ PageSize: 10,
+ Searcher: &User{ID: 14},
+ })
+
+ assert.NotNil(t, repos)
+ assert.NoError(t, err)
+ assert.Equal(t, int64(3), count)
+}
diff --git a/models/repo_test.go b/models/repo_test.go
index ca1259a7ea..7c0e94a5ae 100644
--- a/models/repo_test.go
+++ b/models/repo_test.go
@@ -125,55 +125,3 @@ func TestForkRepository(t *testing.T) {
assert.Error(t, err)
assert.True(t, IsErrRepoAlreadyExist(err))
}
-
-func TestSearchRepositoryByName(t *testing.T) {
- assert.NoError(t, PrepareTestDatabase())
-
- // test search public repository on explore page
- repos, count, err := SearchRepositoryByName(&SearchRepoOptions{
- Keyword: "repo_12",
- Page: 1,
- PageSize: 10,
- Searcher: nil,
- })
-
- assert.NotNil(t, repos)
- assert.NoError(t, err)
- assert.Equal(t, "test_repo_12", repos[0].Name)
- assert.Equal(t, int64(1), count)
-
- repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
- Keyword: "test_repo",
- Page: 1,
- PageSize: 10,
- Searcher: nil,
- })
-
- assert.NotNil(t, repos)
- assert.NoError(t, err)
- assert.Equal(t, int64(2), count)
-
- // test search private repository on explore page
- repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
- Keyword: "repo_13",
- Page: 1,
- PageSize: 10,
- Searcher: &User{ID: 14},
- })
-
- assert.NotNil(t, repos)
- assert.NoError(t, err)
- assert.Equal(t, "test_repo_13", repos[0].Name)
- assert.Equal(t, int64(1), count)
-
- repos, count, err = SearchRepositoryByName(&SearchRepoOptions{
- Keyword: "test_repo",
- Page: 1,
- PageSize: 10,
- Searcher: &User{ID: 14},
- })
-
- assert.NotNil(t, repos)
- assert.NoError(t, err)
- assert.Equal(t, int64(3), count)
-}