summaryrefslogtreecommitdiffstats
path: root/models/repo_permission_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo_permission_test.go')
-rw-r--r--models/repo_permission_test.go31
1 files changed, 16 insertions, 15 deletions
diff --git a/models/repo_permission_test.go b/models/repo_permission_test.go
index 795b5f2115..f2664d8101 100644
--- a/models/repo_permission_test.go
+++ b/models/repo_permission_test.go
@@ -9,6 +9,7 @@ import (
"code.gitea.io/gitea/models/db"
perm_model "code.gitea.io/gitea/models/perm"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -20,8 +21,8 @@ func TestRepoPermissionPublicNonOrgRepo(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
// public non-organization repo
- repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 4}).(*Repository)
- assert.NoError(t, repo.getUnits(db.GetEngine(db.DefaultContext)))
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4}).(*repo_model.Repository)
+ assert.NoError(t, repo.LoadUnits(db.DefaultContext))
// plain user
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
@@ -33,7 +34,7 @@ func TestRepoPermissionPublicNonOrgRepo(t *testing.T) {
}
// change to collaborator
- assert.NoError(t, repo.AddCollaborator(user))
+ assert.NoError(t, AddCollaborator(repo, user))
perm, err = GetUserRepoPermission(repo, user)
assert.NoError(t, err)
for _, unit := range repo.Units {
@@ -73,8 +74,8 @@ func TestRepoPermissionPrivateNonOrgRepo(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
// private non-organization repo
- repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
- assert.NoError(t, repo.getUnits(db.GetEngine(db.DefaultContext)))
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}).(*repo_model.Repository)
+ assert.NoError(t, repo.LoadUnits(db.DefaultContext))
// plain user
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4}).(*user_model.User)
@@ -86,7 +87,7 @@ func TestRepoPermissionPrivateNonOrgRepo(t *testing.T) {
}
// change to collaborator to default write access
- assert.NoError(t, repo.AddCollaborator(user))
+ assert.NoError(t, AddCollaborator(repo, user))
perm, err = GetUserRepoPermission(repo, user)
assert.NoError(t, err)
for _, unit := range repo.Units {
@@ -94,7 +95,7 @@ func TestRepoPermissionPrivateNonOrgRepo(t *testing.T) {
assert.True(t, perm.CanWrite(unit.Type))
}
- assert.NoError(t, repo.ChangeCollaborationAccessMode(user.ID, perm_model.AccessModeRead))
+ assert.NoError(t, ChangeCollaborationAccessMode(repo, user.ID, perm_model.AccessModeRead))
perm, err = GetUserRepoPermission(repo, user)
assert.NoError(t, err)
for _, unit := range repo.Units {
@@ -125,8 +126,8 @@ func TestRepoPermissionPublicOrgRepo(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
// public organization repo
- repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 32}).(*Repository)
- assert.NoError(t, repo.getUnits(db.GetEngine(db.DefaultContext)))
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 32}).(*repo_model.Repository)
+ assert.NoError(t, repo.LoadUnits(db.DefaultContext))
// plain user
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
@@ -138,7 +139,7 @@ func TestRepoPermissionPublicOrgRepo(t *testing.T) {
}
// change to collaborator to default write access
- assert.NoError(t, repo.AddCollaborator(user))
+ assert.NoError(t, AddCollaborator(repo, user))
perm, err = GetUserRepoPermission(repo, user)
assert.NoError(t, err)
for _, unit := range repo.Units {
@@ -146,7 +147,7 @@ func TestRepoPermissionPublicOrgRepo(t *testing.T) {
assert.True(t, perm.CanWrite(unit.Type))
}
- assert.NoError(t, repo.ChangeCollaborationAccessMode(user.ID, perm_model.AccessModeRead))
+ assert.NoError(t, ChangeCollaborationAccessMode(repo, user.ID, perm_model.AccessModeRead))
perm, err = GetUserRepoPermission(repo, user)
assert.NoError(t, err)
for _, unit := range repo.Units {
@@ -187,8 +188,8 @@ func TestRepoPermissionPrivateOrgRepo(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
// private organization repo
- repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 24}).(*Repository)
- assert.NoError(t, repo.getUnits(db.GetEngine(db.DefaultContext)))
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 24}).(*repo_model.Repository)
+ assert.NoError(t, repo.LoadUnits(db.DefaultContext))
// plain user
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
@@ -200,7 +201,7 @@ func TestRepoPermissionPrivateOrgRepo(t *testing.T) {
}
// change to collaborator to default write access
- assert.NoError(t, repo.AddCollaborator(user))
+ assert.NoError(t, AddCollaborator(repo, user))
perm, err = GetUserRepoPermission(repo, user)
assert.NoError(t, err)
for _, unit := range repo.Units {
@@ -208,7 +209,7 @@ func TestRepoPermissionPrivateOrgRepo(t *testing.T) {
assert.True(t, perm.CanWrite(unit.Type))
}
- assert.NoError(t, repo.ChangeCollaborationAccessMode(user.ID, perm_model.AccessModeRead))
+ assert.NoError(t, ChangeCollaborationAccessMode(repo, user.ID, perm_model.AccessModeRead))
perm, err = GetUserRepoPermission(repo, user)
assert.NoError(t, err)
for _, unit := range repo.Units {