refactor(arch): decouple private imports, enforce contracts and comply with cordis architecture

This commit is contained in:
ryan
2026-09-03 10:40:02 +08:00
parent dbcf485d8a
commit 953a224245
107 changed files with 2028 additions and 1263 deletions
@@ -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()
}