summaryrefslogtreecommitdiffstats
path: root/models/repo_test.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-22 21:15:14 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-22 21:15:14 +0800
commit83b6d032318c7ba082531a9d0060b7109094b828 (patch)
tree4f76f95ea7defa5ae6465f63cdbf8659ee32b744 /models/repo_test.go
parentd6748284bd6b4424d0e50cb4b952d12c74203960 (diff)
downloadgitea-83b6d032318c7ba082531a9d0060b7109094b828.tar.gz
gitea-83b6d032318c7ba082531a9d0060b7109094b828.zip
fix: Wrong repo list on Explore page if user already loggin. (#1009)
* fix: Wrong repo list on Explore page if user already loggin. * fix: code readable. * fix: declare variable
Diffstat (limited to 'models/repo_test.go')
-rw-r--r--models/repo_test.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/models/repo_test.go b/models/repo_test.go
index 7c0e94a5ae..ca1259a7ea 100644
--- a/models/repo_test.go
+++ b/models/repo_test.go
@@ -125,3 +125,55 @@ 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)
+}