aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository/collaboration_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-11-06 19:28:11 -0800
committerGitHub <noreply@github.com>2024-11-07 11:28:11 +0800
commit276500c314db1c0ef360088753861ffc010a99da (patch)
tree2e03a4daa7f38bfaa607b4fefe6e161d88bd724a /services/repository/collaboration_test.go
parent913be9e8ac1b745c9eb6dda06146e090166c8b79 (diff)
downloadgitea-276500c314db1c0ef360088753861ffc010a99da.tar.gz
gitea-276500c314db1c0ef360088753861ffc010a99da.zip
Move AddCollabrator and CreateRepositoryByExample to service layer (#32419)
- [x] Move `CreateRepositoryByExample` to service layer - [x] Move `AddCollabrator` to service layer - [x] Add a new parameter for `AddCollabrator` so that changing mode immediately after that will become unnecessary.
Diffstat (limited to 'services/repository/collaboration_test.go')
-rw-r--r--services/repository/collaboration_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/services/repository/collaboration_test.go b/services/repository/collaboration_test.go
index a2eb06b81a..2b9a5d0b8b 100644
--- a/services/repository/collaboration_test.go
+++ b/services/repository/collaboration_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/perm"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -14,6 +15,21 @@ import (
"github.com/stretchr/testify/assert"
)
+func TestRepository_AddCollaborator(t *testing.T) {
+ assert.NoError(t, unittest.PrepareTestDatabase())
+
+ testSuccess := func(repoID, userID int64) {
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repoID})
+ assert.NoError(t, repo.LoadOwner(db.DefaultContext))
+ user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
+ assert.NoError(t, AddOrUpdateCollaborator(db.DefaultContext, repo, user, perm.AccessModeWrite))
+ unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repoID}, &user_model.User{ID: userID})
+ }
+ testSuccess(1, 4)
+ testSuccess(1, 4)
+ testSuccess(3, 4)
+}
+
func TestRepository_DeleteCollaboration(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())