diff options
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/api_repo_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go index 8073f773ac..e89a6359ae 100644 --- a/integrations/api_repo_test.go +++ b/integrations/api_repo_test.go @@ -63,3 +63,24 @@ func TestAPIViewRepo(t *testing.T) { assert.EqualValues(t, 1, repo.ID) assert.EqualValues(t, "repo1", repo.Name) } + +func TestAPIOrgRepos(t *testing.T) { + prepareTestEnv(t) + user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) + // User3 is an Org. Check their repos. + sourceOrg := models.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User) + // Login as User2. + session := loginUser(t, user.Name) + + req := NewRequestf(t, "GET", "/api/v1/orgs/%s/repos", sourceOrg.Name) + resp := session.MakeRequest(t, req, http.StatusOK) + + var apiRepos []*api.Repository + DecodeJSON(t, resp, &apiRepos) + expectedLen := models.GetCount(t, models.Repository{OwnerID: sourceOrg.ID}, + models.Cond("is_private = ?", false)) + assert.Len(t, apiRepos, expectedLen) + for _, repo := range apiRepos { + assert.False(t, repo.Private) + } +} |