aboutsummaryrefslogtreecommitdiffstats
path: root/models/organization/team_repo_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/organization/team_repo_test.go')
-rw-r--r--models/organization/team_repo_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/models/organization/team_repo_test.go b/models/organization/team_repo_test.go
new file mode 100644
index 0000000000..c0d6750df9
--- /dev/null
+++ b/models/organization/team_repo_test.go
@@ -0,0 +1,31 @@
+// Copyright 2024 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package organization_test
+
+import (
+ "testing"
+
+ "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/organization"
+ "code.gitea.io/gitea/models/perm"
+ "code.gitea.io/gitea/models/repo"
+ "code.gitea.io/gitea/models/unit"
+ "code.gitea.io/gitea/models/unittest"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestGetTeamsWithAccessToRepoUnit(t *testing.T) {
+ assert.NoError(t, unittest.PrepareTestDatabase())
+
+ org41 := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 41})
+ repo61 := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 61})
+
+ teams, err := organization.GetTeamsWithAccessToRepoUnit(db.DefaultContext, org41.ID, repo61.ID, perm.AccessModeRead, unit.TypePullRequests)
+ assert.NoError(t, err)
+ if assert.Len(t, teams, 2) {
+ assert.EqualValues(t, 21, teams[0].ID)
+ assert.EqualValues(t, 22, teams[1].ID)
+ }
+}