aboutsummaryrefslogtreecommitdiffstats
path: root/models/org_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-10-15 23:46:06 +0800
committerGitHub <noreply@github.com>2023-10-15 17:46:06 +0200
commitcddf245c12223c783c856c87c21cc796ac425439 (patch)
tree21edf50797c62c3e70dbada95edc20d7ddfd53b8 /models/org_test.go
parent7480aacdad9470458fa0142beab54b8011bbac25 (diff)
downloadgitea-cddf245c12223c783c856c87c21cc796ac425439.tar.gz
gitea-cddf245c12223c783c856c87c21cc796ac425439.zip
Replace more db.DefaultContext (#27628)
Target #27065
Diffstat (limited to 'models/org_test.go')
-rw-r--r--models/org_test.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/models/org_test.go b/models/org_test.go
index 54e8f08465..d10a1dc218 100644
--- a/models/org_test.go
+++ b/models/org_test.go
@@ -6,6 +6,7 @@ package models
import (
"testing"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -20,7 +21,7 @@ func TestUser_RemoveMember(t *testing.T) {
// remove a user that is a member
unittest.AssertExistsAndLoadBean(t, &organization.OrgUser{UID: 4, OrgID: 3})
prevNumMembers := org.NumMembers
- assert.NoError(t, RemoveOrgUser(org.ID, 4))
+ assert.NoError(t, RemoveOrgUser(db.DefaultContext, org.ID, 4))
unittest.AssertNotExistsBean(t, &organization.OrgUser{UID: 4, OrgID: 3})
org = unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3})
assert.Equal(t, prevNumMembers-1, org.NumMembers)
@@ -28,7 +29,7 @@ func TestUser_RemoveMember(t *testing.T) {
// remove a user that is not a member
unittest.AssertNotExistsBean(t, &organization.OrgUser{UID: 5, OrgID: 3})
prevNumMembers = org.NumMembers
- assert.NoError(t, RemoveOrgUser(org.ID, 5))
+ assert.NoError(t, RemoveOrgUser(db.DefaultContext, org.ID, 5))
unittest.AssertNotExistsBean(t, &organization.OrgUser{UID: 5, OrgID: 3})
org = unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3})
assert.Equal(t, prevNumMembers, org.NumMembers)
@@ -44,7 +45,7 @@ func TestRemoveOrgUser(t *testing.T) {
if unittest.BeanExists(t, &organization.OrgUser{OrgID: orgID, UID: userID}) {
expectedNumMembers--
}
- assert.NoError(t, RemoveOrgUser(orgID, userID))
+ assert.NoError(t, RemoveOrgUser(db.DefaultContext, orgID, userID))
unittest.AssertNotExistsBean(t, &organization.OrgUser{OrgID: orgID, UID: userID})
org = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: orgID})
assert.EqualValues(t, expectedNumMembers, org.NumMembers)
@@ -52,7 +53,7 @@ func TestRemoveOrgUser(t *testing.T) {
testSuccess(3, 4)
testSuccess(3, 4)
- err := RemoveOrgUser(7, 5)
+ err := RemoveOrgUser(db.DefaultContext, 7, 5)
assert.Error(t, err)
assert.True(t, organization.IsErrLastOrgOwner(err))
unittest.AssertExistsAndLoadBean(t, &organization.OrgUser{OrgID: 7, UID: 5})