aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_utils.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-02-23 15:11:56 +0100
committerGitHub <noreply@github.com>2023-02-23 22:11:56 +0800
commit0ae1ed749dd6581379b7ccf483d66051869b52d7 (patch)
tree0522d4888f51b9056e55a93dcb5bd46f2726ef2f /tests/test_utils.go
parent3adfc0f02d1440d22934403b8d944218747b9289 (diff)
downloadgitea-0ae1ed749dd6581379b7ccf483d66051869b52d7.tar.gz
gitea-0ae1ed749dd6581379b7ccf483d66051869b52d7.zip
Remove all package data after tests (#22984)
Fixes #21020 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'tests/test_utils.go')
-rw-r--r--tests/test_utils.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_utils.go b/tests/test_utils.go
index 9e9f97a5f5..5cc31b814e 100644
--- a/tests/test_utils.go
+++ b/tests/test_utils.go
@@ -13,6 +13,8 @@ import (
"runtime"
"testing"
+ "code.gitea.io/gitea/models/db"
+ packages_model "code.gitea.io/gitea/models/packages"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/git"
@@ -204,6 +206,18 @@ func PrepareTestEnv(t testing.TB, skip ...int) func() {
return err
}))
+ // clear all package data
+ assert.NoError(t, db.TruncateBeans(db.DefaultContext,
+ &packages_model.Package{},
+ &packages_model.PackageVersion{},
+ &packages_model.PackageFile{},
+ &packages_model.PackageBlob{},
+ &packages_model.PackageProperty{},
+ &packages_model.PackageBlobUpload{},
+ &packages_model.PackageCleanupRule{},
+ ))
+ assert.NoError(t, storage.Clean(storage.Packages))
+
return deferFn
}