summaryrefslogtreecommitdiffstats
path: root/integrations/api_repo_test.go
diff options
context:
space:
mode:
authorMorlinest <morlinest@gmail.com>2017-10-17 17:20:22 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-10-17 23:20:22 +0800
commitccd3577970b64078eb156a736b1583833f80b4a3 (patch)
tree4abdd588adfc3f24992953ba2ad6fe0dcf614a6e /integrations/api_repo_test.go
parentaf4a094e5d1be13c0fe863c1cd6e56c62b1a9b79 (diff)
downloadgitea-ccd3577970b64078eb156a736b1583833f80b4a3.tar.gz
gitea-ccd3577970b64078eb156a736b1583833f80b4a3.zip
Fix repository search function (#2689)
* Fix and remove FIXME * Respect membership visibility * Fix/rewrite searchRepositoryByName function * Add unit tests * Add integration tests * Remove Searcher completely * Remove trailing space
Diffstat (limited to 'integrations/api_repo_test.go')
-rw-r--r--integrations/api_repo_test.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go
index c536b8d329..f517ee42cd 100644
--- a/integrations/api_repo_test.go
+++ b/integrations/api_repo_test.go
@@ -50,6 +50,7 @@ func TestAPISearchRepo(t *testing.T) {
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 15}).(*models.User)
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 16}).(*models.User)
+ user3 := models.AssertExistsAndLoadBean(t, &models.User{ID: 18}).(*models.User)
orgUser := models.AssertExistsAndLoadBean(t, &models.User{ID: 17}).(*models.User)
// Map of expected results, where key is user for login
@@ -85,17 +86,21 @@ func TestAPISearchRepo(t *testing.T) {
user2: {count: 4, repoName: "big_test_"}},
},
{name: "RepositoriesAccessibleAndRelatedToUser", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", user.ID), expectedResults: expectedResults{
- // FIXME: Should return 4 (all public repositories related to "another" user = owned + collaborative), now returns only public repositories directly owned by user
- nil: {count: 2},
- user: {count: 8, includesPrivate: true},
- // FIXME: Should return 4 (all public repositories related to "another" user = owned + collaborative), now returns only public repositories directly owned by user
- user2: {count: 2}},
+ nil: {count: 4},
+ user: {count: 8, includesPrivate: true},
+ user2: {count: 4}},
},
{name: "RepositoriesAccessibleAndRelatedToUser2", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", user2.ID), expectedResults: expectedResults{
nil: {count: 1},
user: {count: 1},
user2: {count: 2, includesPrivate: true}},
},
+ {name: "RepositoriesAccessibleAndRelatedToUser3", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", user3.ID), expectedResults: expectedResults{
+ nil: {count: 1},
+ user: {count: 1},
+ user2: {count: 1},
+ user3: {count: 4, includesPrivate: true}},
+ },
{name: "RepositoriesOwnedByOrganization", requestURL: fmt.Sprintf("/api/v1/repos/search?uid=%d", orgUser.ID), expectedResults: expectedResults{
nil: {count: 1, repoOwnerID: orgUser.ID},
user: {count: 2, repoOwnerID: orgUser.ID, includesPrivate: true},