diff options
Diffstat (limited to 'models/repo/collaboration_test.go')
-rw-r--r-- | models/repo/collaboration_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/models/repo/collaboration_test.go b/models/repo/collaboration_test.go index 8cb7980a75..2e6253d561 100644 --- a/models/repo/collaboration_test.go +++ b/models/repo/collaboration_test.go @@ -8,6 +8,8 @@ import ( "testing" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/perm" + access_model "code.gitea.io/gitea/models/perm/access" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" @@ -48,3 +50,22 @@ func TestRepository_IsCollaborator(t *testing.T) { test(4, 2, false) test(4, 4, true) } + +func TestRepository_ChangeCollaborationAccessMode(t *testing.T) { + assert.NoError(t, unittest.PrepareTestDatabase()) + + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4}).(*repo_model.Repository) + assert.NoError(t, repo_model.ChangeCollaborationAccessMode(repo, 4, perm.AccessModeAdmin)) + + collaboration := unittest.AssertExistsAndLoadBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: 4}).(*repo_model.Collaboration) + assert.EqualValues(t, perm.AccessModeAdmin, collaboration.Mode) + + access := unittest.AssertExistsAndLoadBean(t, &access_model.Access{UserID: 4, RepoID: repo.ID}).(*access_model.Access) + assert.EqualValues(t, perm.AccessModeAdmin, access.Mode) + + assert.NoError(t, repo_model.ChangeCollaborationAccessMode(repo, 4, perm.AccessModeAdmin)) + + assert.NoError(t, repo_model.ChangeCollaborationAccessMode(repo, unittest.NonexistentID, perm.AccessModeAdmin)) + + unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repo.ID}) +} |