mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 09:46:37 +08:00
refactor(arch): decouple private imports, enforce contracts and comply with cordis architecture
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"database/sql"
|
||||
"testing"
|
||||
|
||||
db "Wavelet/plugins/infra/database"
|
||||
"Wavelet/openflare/plugins/server/kernel/repository"
|
||||
|
||||
"github.com/glebarez/sqlite"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -65,10 +65,10 @@ func setupLegacyImportDB(t *testing.T) (*sql.DB, func()) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
previous := db.DB(context.Background())
|
||||
db.SetDB(gormDB)
|
||||
previous := repository.DB(context.Background())
|
||||
repository.SetDBForTest(gormDB)
|
||||
return sqlDB, func() {
|
||||
db.SetDB(previous)
|
||||
repository.SetDBForTest(previous)
|
||||
_ = sqlDB.Close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"Wavelet/openflare/plugins/server/kernel/testhelper"
|
||||
|
||||
"Wavelet/openflare/plugins/server/kernel/model"
|
||||
db "Wavelet/plugins/infra/database"
|
||||
|
||||
"github.com/glebarez/sqlite"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -24,8 +23,8 @@ func setupZoneDB(t *testing.T) context.Context {
|
||||
conn, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{DisableForeignKeyConstraintWhenMigrating: true})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, conn.AutoMigrate(&model.Zone{}, &model.ZoneDomain{}, &model.TLSCertificate{}, &model.CFPointingGroup{}, &model.CFPointingMember{}))
|
||||
db.SetDB(conn)
|
||||
t.Cleanup(func() { db.SetDB(nil) })
|
||||
repository.SetDBForTest(conn)
|
||||
t.Cleanup(func() { repository.SetDBForTest(nil) })
|
||||
return context.Background()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user