From cddf245c12223c783c856c87c21cc796ac425439 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 15 Oct 2023 23:46:06 +0800 Subject: Replace more db.DefaultContext (#27628) Target #27065 --- models/org_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'models/org_test.go') 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}) -- cgit v1.2.3