From 6a3c03762a37f593ec8101c2005836ca44683e1d Mon Sep 17 00:00:00 2001 From: Aaron Walker Date: Thu, 13 Jul 2017 04:14:15 -0700 Subject: API: support '/orgs/:org/repos' (#2047) * API: support '/orgs/:org/repos' --- integrations/api_repo_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'integrations/api_repo_test.go') 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) + } +} -- cgit v1.2.3