aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/dbtest/dbtest.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/dbtest/dbtest.go b/internal/dbtest/dbtest.go
index 4e6b7e6a..5fab7b13 100644
--- a/internal/dbtest/dbtest.go
+++ b/internal/dbtest/dbtest.go
@@ -55,7 +55,12 @@ func NewDB(t *testing.T, suite string, tables ...any) *gorm.DB {
dbOpts.Name = dbName
- cleanup = func(_ *gorm.DB) {
+ cleanup = func(db *gorm.DB) {
+ testDB, err := db.DB()
+ if err == nil {
+ _ = testDB.Close()
+ }
+
_, _ = sqlDB.Exec(fmt.Sprintf("DROP DATABASE `%s`", dbName))
_ = sqlDB.Close()
}
@@ -86,7 +91,12 @@ func NewDB(t *testing.T, suite string, tables ...any) *gorm.DB {
dbOpts.Name = dbName
- cleanup = func(_ *gorm.DB) {
+ cleanup = func(db *gorm.DB) {
+ testDB, err := db.DB()
+ if err == nil {
+ _ = testDB.Close()
+ }
+
_, _ = sqlDB.Exec(fmt.Sprintf(`DROP DATABASE %q`, dbName))
_ = sqlDB.Close()
}