|
|
@ -17,9 +17,11 @@ func TestSearchRepository(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// test search public repository on explore page
|
|
|
|
// test search public repository on explore page
|
|
|
|
repos, count, err := SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
repos, count, err := SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
Keyword: "repo_12", |
|
|
|
ListOptions: ListOptions{ |
|
|
|
Page: 1, |
|
|
|
Page: 1, |
|
|
|
PageSize: 10, |
|
|
|
PageSize: 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Keyword: "repo_12", |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -30,9 +32,11 @@ func TestSearchRepository(t *testing.T) { |
|
|
|
assert.Equal(t, int64(1), count) |
|
|
|
assert.Equal(t, int64(1), count) |
|
|
|
|
|
|
|
|
|
|
|
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
Keyword: "test_repo", |
|
|
|
ListOptions: ListOptions{ |
|
|
|
Page: 1, |
|
|
|
Page: 1, |
|
|
|
PageSize: 10, |
|
|
|
PageSize: 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Keyword: "test_repo", |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -42,9 +46,11 @@ func TestSearchRepository(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// test search private repository on explore page
|
|
|
|
// test search private repository on explore page
|
|
|
|
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
Keyword: "repo_13", |
|
|
|
ListOptions: ListOptions{ |
|
|
|
Page: 1, |
|
|
|
Page: 1, |
|
|
|
PageSize: 10, |
|
|
|
PageSize: 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Keyword: "repo_13", |
|
|
|
Private: true, |
|
|
|
Private: true, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -56,9 +62,11 @@ func TestSearchRepository(t *testing.T) { |
|
|
|
assert.Equal(t, int64(1), count) |
|
|
|
assert.Equal(t, int64(1), count) |
|
|
|
|
|
|
|
|
|
|
|
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
repos, count, err = SearchRepositoryByName(&SearchRepoOptions{ |
|
|
|
Keyword: "test_repo", |
|
|
|
ListOptions: ListOptions{ |
|
|
|
Page: 1, |
|
|
|
Page: 1, |
|
|
|
PageSize: 10, |
|
|
|
PageSize: 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Keyword: "test_repo", |
|
|
|
Private: true, |
|
|
|
Private: true, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -76,9 +84,11 @@ func TestSearchRepository(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Test search within description
|
|
|
|
// Test search within description
|
|
|
|
repos, count, err = SearchRepository(&SearchRepoOptions{ |
|
|
|
repos, count, err = SearchRepository(&SearchRepoOptions{ |
|
|
|
Keyword: "description_14", |
|
|
|
ListOptions: ListOptions{ |
|
|
|
Page: 1, |
|
|
|
Page: 1, |
|
|
|
PageSize: 10, |
|
|
|
PageSize: 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Keyword: "description_14", |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
IncludeDescription: true, |
|
|
|
IncludeDescription: true, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -91,9 +101,11 @@ func TestSearchRepository(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Test NOT search within description
|
|
|
|
// Test NOT search within description
|
|
|
|
repos, count, err = SearchRepository(&SearchRepoOptions{ |
|
|
|
repos, count, err = SearchRepository(&SearchRepoOptions{ |
|
|
|
Keyword: "description_14", |
|
|
|
ListOptions: ListOptions{ |
|
|
|
Page: 1, |
|
|
|
Page: 1, |
|
|
|
PageSize: 10, |
|
|
|
PageSize: 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Keyword: "description_14", |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
Collaborate: util.OptionalBoolFalse, |
|
|
|
IncludeDescription: false, |
|
|
|
IncludeDescription: false, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -108,88 +120,88 @@ func TestSearchRepository(t *testing.T) { |
|
|
|
count int |
|
|
|
count int |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
{name: "PublicRepositoriesByName", |
|
|
|
{name: "PublicRepositoriesByName", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", PageSize: 10, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{PageSize: 10}, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 7}, |
|
|
|
count: 7}, |
|
|
|
{name: "PublicAndPrivateRepositoriesByName", |
|
|
|
{name: "PublicAndPrivateRepositoriesByName", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 1, PageSize: 10, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{Page: 1, PageSize: 10}, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 14}, |
|
|
|
count: 14}, |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitFirstPage", |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitFirstPage", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 1, PageSize: 5, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{Page: 1, PageSize: 5}, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 14}, |
|
|
|
count: 14}, |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitSecondPage", |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitSecondPage", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 2, PageSize: 5, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{Page: 2, PageSize: 5}, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 14}, |
|
|
|
count: 14}, |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitThirdPage", |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitThirdPage", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 3, PageSize: 5, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{Page: 3, PageSize: 5}, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 14}, |
|
|
|
count: 14}, |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitFourthPage", |
|
|
|
{name: "PublicAndPrivateRepositoriesByNameWithPagesizeLimitFourthPage", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 3, PageSize: 5, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{Page: 3, PageSize: 5}, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 14}, |
|
|
|
count: 14}, |
|
|
|
{name: "PublicRepositoriesOfUser", |
|
|
|
{name: "PublicRepositoriesOfUser", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 2}, |
|
|
|
count: 2}, |
|
|
|
{name: "PublicRepositoriesOfUser2", |
|
|
|
{name: "PublicRepositoriesOfUser2", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 18, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 18, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 0}, |
|
|
|
count: 0}, |
|
|
|
{name: "PublicRepositoriesOfUser3", |
|
|
|
{name: "PublicRepositoriesOfUser3", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 20, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 20, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 2}, |
|
|
|
count: 2}, |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser", |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 4}, |
|
|
|
count: 4}, |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser2", |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser2", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 18, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 18, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 0}, |
|
|
|
count: 0}, |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser3", |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser3", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 20, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 20, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 4}, |
|
|
|
count: 4}, |
|
|
|
{name: "PublicRepositoriesOfUserIncludingCollaborative", |
|
|
|
{name: "PublicRepositoriesOfUserIncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 15}, |
|
|
|
count: 5}, |
|
|
|
count: 5}, |
|
|
|
{name: "PublicRepositoriesOfUser2IncludingCollaborative", |
|
|
|
{name: "PublicRepositoriesOfUser2IncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 18}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 18}, |
|
|
|
count: 1}, |
|
|
|
count: 1}, |
|
|
|
{name: "PublicRepositoriesOfUser3IncludingCollaborative", |
|
|
|
{name: "PublicRepositoriesOfUser3IncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 20}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 20}, |
|
|
|
count: 3}, |
|
|
|
count: 3}, |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUserIncludingCollaborative", |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUserIncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, Private: true}, |
|
|
|
count: 9}, |
|
|
|
count: 9}, |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser2IncludingCollaborative", |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser2IncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 18, Private: true}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 18, Private: true}, |
|
|
|
count: 4}, |
|
|
|
count: 4}, |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser3IncludingCollaborative", |
|
|
|
{name: "PublicAndPrivateRepositoriesOfUser3IncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 20, Private: true}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 20, Private: true}, |
|
|
|
count: 7}, |
|
|
|
count: 7}, |
|
|
|
{name: "PublicRepositoriesOfOrganization", |
|
|
|
{name: "PublicRepositoriesOfOrganization", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 17, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 17, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 1}, |
|
|
|
count: 1}, |
|
|
|
{name: "PublicAndPrivateRepositoriesOfOrganization", |
|
|
|
{name: "PublicAndPrivateRepositoriesOfOrganization", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 17, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 17, Private: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 2}, |
|
|
|
count: 2}, |
|
|
|
{name: "AllPublic/PublicRepositoriesByName", |
|
|
|
{name: "AllPublic/PublicRepositoriesByName", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", PageSize: 10, AllPublic: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{PageSize: 10}, AllPublic: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 7}, |
|
|
|
count: 7}, |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesByName", |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesByName", |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", Page: 1, PageSize: 10, Private: true, AllPublic: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "big_test_", ListOptions: ListOptions{Page: 1, PageSize: 10}, Private: true, AllPublic: true, Collaborate: util.OptionalBoolFalse}, |
|
|
|
count: 14}, |
|
|
|
count: 14}, |
|
|
|
{name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative", |
|
|
|
{name: "AllPublic/PublicRepositoriesOfUserIncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, AllPublic: true, Template: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, AllPublic: true, Template: util.OptionalBoolFalse}, |
|
|
|
count: 25}, |
|
|
|
count: 25}, |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative", |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true, AllLimited: true, Template: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, Private: true, AllPublic: true, AllLimited: true, Template: util.OptionalBoolFalse}, |
|
|
|
count: 30}, |
|
|
|
count: 30}, |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName", |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName", |
|
|
|
opts: &SearchRepoOptions{Keyword: "test", Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "test", ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 15, Private: true, AllPublic: true}, |
|
|
|
count: 15}, |
|
|
|
count: 15}, |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesOfUser2IncludingCollaborativeByName", |
|
|
|
{name: "AllPublic/PublicAndPrivateRepositoriesOfUser2IncludingCollaborativeByName", |
|
|
|
opts: &SearchRepoOptions{Keyword: "test", Page: 1, PageSize: 10, OwnerID: 18, Private: true, AllPublic: true}, |
|
|
|
opts: &SearchRepoOptions{Keyword: "test", ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 18, Private: true, AllPublic: true}, |
|
|
|
count: 13}, |
|
|
|
count: 13}, |
|
|
|
{name: "AllPublic/PublicRepositoriesOfOrganization", |
|
|
|
{name: "AllPublic/PublicRepositoriesOfOrganization", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 17, AllPublic: true, Collaborate: util.OptionalBoolFalse, Template: util.OptionalBoolFalse}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, OwnerID: 17, AllPublic: true, Collaborate: util.OptionalBoolFalse, Template: util.OptionalBoolFalse}, |
|
|
|
count: 25}, |
|
|
|
count: 25}, |
|
|
|
{name: "AllTemplates", |
|
|
|
{name: "AllTemplates", |
|
|
|
opts: &SearchRepoOptions{Page: 1, PageSize: 10, Template: util.OptionalBoolTrue}, |
|
|
|
opts: &SearchRepoOptions{ListOptions: ListOptions{Page: 1, PageSize: 10}, Template: util.OptionalBoolTrue}, |
|
|
|
count: 2}, |
|
|
|
count: 2}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|