重构:统一应用服务与基础设施适配边界
将账号、认证、管理员、分析、自动化、卡券、聊天、商品、关键词、设置和订单能力迁移到 application 与 adapter,删除 Server 内对应的旧仓储和业务服务实现,并收紧架构检查。 完善批量发布与订单刷新生命周期、凭证写回、账号任务补偿、订单 reconciliation、通知和敏感数据边界;补充正常、失败、取消、并发、越权及多方言回归测试,并修正 MySQL 延迟任务表的 InnoDB 配置。 修复空卡密响应为 null 时前端加载失败的问题,重建嵌入式前端资产;重写重构总计划,清除历史流水并明确阶段 1 至 10 各对应一次完整迭代和一个 PR。 验证:make check;make test-server-race;npm test/typecheck/comments:check/build;Docker SQLite/MySQL 8.4/PostgreSQL 17 TestMultiDB_*。
This commit is contained in:
1 parent
19a7d5f924
commit
375e84d663
239 files changed
+23870
-7871
No files matched your search
@@ -7,6 +7,9 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"xianyu-go/internal/adapter"
|
||||
"xianyu-go/internal/auth"
|
||||
)
|
||||
|
||||
// freeAddr 获取一个空闲 TCP 端口(立即释放,供测试绑定)。
|
||||
@@ -122,18 +125,25 @@ func TestPublishRecoveryLifecycleStopsBeforeWorkerWait(t *testing.T) {
|
||||
|
||||
// TestNewRejectsMissingRequiredDependencies 确保 HTTP 服务构造阶段拒绝缺失核心依赖。
|
||||
func TestNewRejectsMissingRequiredDependencies(t *testing.T) {
|
||||
// err 是缺少 Store 时的构造校验错误。
|
||||
if _, err := New(nil, nil, false, "", ":0", nil, nil, nil); err == nil {
|
||||
t.Fatal("缺少 db.Store 时应返回构造错误")
|
||||
// err 是缺少基础设施容器时的构造校验错误。
|
||||
if _, err := New(nil, nil, nil, "", ":0", nil, nil, nil); err == nil {
|
||||
t.Fatal("缺少基础设施容器时应返回构造错误")
|
||||
}
|
||||
// srv 是用于提供合法 Store 的测试服务;cleanup 负责释放测试数据库。
|
||||
srv, _, cleanup := newTestServer(t)
|
||||
srv, store, cleanup := newTestServer(t)
|
||||
defer cleanup()
|
||||
if srv == nil {
|
||||
t.Fatal("测试服务不应为空")
|
||||
}
|
||||
// dependencies 保存缺少 Manager 校验时复用的基础设施容器。
|
||||
dependencies, dependencyErr := adapter.NewDependencies(store)
|
||||
if dependencyErr != nil {
|
||||
t.Fatalf("NewDependencies: %v", dependencyErr)
|
||||
}
|
||||
// authentication 保存构造校验需要的会话中间件依赖。
|
||||
authentication := &auth.Service{Store: store}
|
||||
// err 是缺少 Manager 时的构造校验错误。
|
||||
if _, err := New(srv.Store, nil, false, "", ":0", nil, nil, nil); err == nil {
|
||||
if _, err := New(dependencies, authentication, nil, "", ":0", nil, nil, nil); err == nil {
|
||||
t.Fatal("缺少 account.Manager 时应返回构造错误")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user