aboutsummaryrefslogtreecommitdiffstats
path: root/services/org
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 /services/org
parent7480aacdad9470458fa0142beab54b8011bbac25 (diff)
downloadgitea-cddf245c12223c783c856c87c21cc796ac425439.tar.gz
gitea-cddf245c12223c783c856c87c21cc796ac425439.zip
Replace more db.DefaultContext (#27628)
Target #27065
Diffstat (limited to 'services/org')
-rw-r--r--services/org/org.go4
-rw-r--r--services/org/org_test.go7
2 files changed, 6 insertions, 5 deletions
diff --git a/services/org/org.go b/services/org/org.go
index a62e5b6fc8..4ecafc93a6 100644
--- a/services/org/org.go
+++ b/services/org/org.go
@@ -19,8 +19,8 @@ import (
)
// DeleteOrganization completely and permanently deletes everything of organization.
-func DeleteOrganization(org *org_model.Organization) error {
- ctx, commiter, err := db.TxContext(db.DefaultContext)
+func DeleteOrganization(ctx context.Context, org *org_model.Organization) error {
+ ctx, commiter, err := db.TxContext(ctx)
if err != nil {
return err
}
diff --git a/services/org/org_test.go b/services/org/org_test.go
index 339646795d..763c708c14 100644
--- a/services/org/org_test.go
+++ b/services/org/org_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ "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"
@@ -21,17 +22,17 @@ func TestMain(m *testing.M) {
func TestDeleteOrganization(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 6})
- assert.NoError(t, DeleteOrganization(org))
+ assert.NoError(t, DeleteOrganization(db.DefaultContext, org))
unittest.AssertNotExistsBean(t, &organization.Organization{ID: 6})
unittest.AssertNotExistsBean(t, &organization.OrgUser{OrgID: 6})
unittest.AssertNotExistsBean(t, &organization.Team{OrgID: 6})
org = unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3})
- err := DeleteOrganization(org)
+ err := DeleteOrganization(db.DefaultContext, org)
assert.Error(t, err)
assert.True(t, models.IsErrUserOwnRepos(err))
user := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 5})
- assert.Error(t, DeleteOrganization(user))
+ assert.Error(t, DeleteOrganization(db.DefaultContext, user))
unittest.CheckConsistencyFor(t, &user_model.User{}, &organization.Team{})
}