|
|
|
@ -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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|