1
0

feat: 系统性改进后端测试体系

- 新增 6 个测试场景 (config load pipe, handler errors, service aggregation, engine degradation, openai decoder edges, negative tests)
- 更新测试工具规格 (mockgen, in-memory SQLite)
- 覆盖率目标从 >80% 提升至 >85%
- 新增 test-unit 和 test-integration Makefile 命令
- 新增死代码清理和 mockgen 需求
- 归档变更至 openspec/changes/archive/2026-04-22-improve-backend-testing/
This commit is contained in:
2026-04-22 13:18:51 +08:00
parent 59179094ed
commit 4e86adffb7
32 changed files with 3374 additions and 729 deletions

View File

@@ -1,4 +1,4 @@
.PHONY: build run test test-coverage clean migrate-up migrate-down migrate-status migrate-create lint
.PHONY: build run test test-unit test-integration test-coverage clean migrate-up migrate-down migrate-status migrate-create lint generate deps
# 构建
build:
@@ -12,6 +12,14 @@ run:
test:
go test ./... -v
# 单元测试
test-unit:
go test ./internal/... ./pkg/... -v
# 集成测试
test-integration:
go test ./tests/... -v
# 测试覆盖率
test-coverage:
go test ./... -coverprofile=coverage.out
@@ -38,8 +46,12 @@ migrate-create:
# 代码检查
lint:
golangci-lint run ./...
go tool golangci-lint run ./...
# 安装依赖
deps:
go mod tidy
# 生成代码mock 等)
generate:
go generate ./...