aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_list_test.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2018-09-13 10:33:48 +0800
committerGitHub <noreply@github.com>2018-09-13 10:33:48 +0800
commitea20adaa84cbff762fcaa7f2d5fa6b7bf56706ec (patch)
treec2d09da1dcb0a00654963b30dbf5eeb152c83857 /models/repo_list_test.go
parent7dd93b2441fc4eac89ccf6b919bf46823334c8bf (diff)
downloadgitea-ea20adaa84cbff762fcaa7f2d5fa6b7bf56706ec.tar.gz
gitea-ea20adaa84cbff762fcaa7f2d5fa6b7bf56706ec.zip
feat(repo): support search repository by topic name (#4505)
* feat(repo): support search repository by topic name
Diffstat (limited to 'models/repo_list_test.go')
-rw-r--r--models/repo_list_test.go31
1 files changed, 28 insertions, 3 deletions
diff --git a/models/repo_list_test.go b/models/repo_list_test.go
index 4b5d659ce2..8f4947dbb2 100644
--- a/models/repo_list_test.go
+++ b/models/repo_list_test.go
@@ -147,10 +147,10 @@ func TestSearchRepositoryByName(t *testing.T) {
count: 14},
{name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative",
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, AllPublic: true},
- count: 17},
+ count: 19},
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative",
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true},
- count: 21},
+ count: 23},
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName",
opts: &SearchRepoOptions{Keyword: "test", Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true},
count: 13},
@@ -159,7 +159,7 @@ func TestSearchRepositoryByName(t *testing.T) {
count: 11},
{name: "AllPublic/PublicRepositoriesOfOrganization",
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 17, AllPublic: true, Collaborate: util.OptionalBoolFalse},
- count: 17},
+ count: 19},
}
for _, testCase := range testCases {
@@ -222,3 +222,28 @@ func TestSearchRepositoryByName(t *testing.T) {
})
}
}
+
+func TestSearchRepositoryByTopicName(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ testCases := []struct {
+ name string
+ opts *SearchRepoOptions
+ count int
+ }{
+ {name: "AllPublic/SearchPublicRepositoriesFromTopicAndName",
+ opts: &SearchRepoOptions{OwnerID: 21, AllPublic: true, Keyword: "graphql"},
+ count: 2},
+ {name: "AllPublic/OnlySearchPublicRepositoriesFromTopic",
+ opts: &SearchRepoOptions{OwnerID: 21, AllPublic: true, Keyword: "graphql", TopicOnly: true},
+ count: 1},
+ }
+
+ for _, testCase := range testCases {
+ t.Run(testCase.name, func(t *testing.T) {
+ _, count, err := SearchRepositoryByName(testCase.opts)
+ assert.NoError(t, err)
+ assert.Equal(t, int64(testCase.count), count)
+ })
+ }
+}