Files
ez-api/TESTING.md
zenfun 71c183a480 test(service): add golden file validation and master key tests
- Update TESTING.md to reflect current testing status and future plans
- Add golden file comparison for provider snapshot validation in sync_test.go
- Introduce master_test.go for testing Master/Key functionality
- Add testdata directory for contract testing snapshots
2025-12-14 23:37:16 +08:00

52 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Testing (ez-api)
本仓库的单元测试采用 Go 标准组织方式:单元测试与源码同目录(`*_test.go`),默认通过 `go test ./...` 运行。
此外,本仓库仍保留 `./test` 下的 docker-compose 集成测试(带 `integration` tag用于端到端验证。
## 运行
### 单元测试
```bash
go test ./...
```
### 集成测试docker compose
```bash
./test/integration.sh
```
## 说明
- 单元测试不依赖 Docker不访问公网。
- 对 Redis 相关逻辑优先使用 `miniredis`(纯内存、接近真实命令行为)。
- 对 DB 相关逻辑优先使用 sqlite in-memory只用于测试避免引入外部依赖。
## 分阶段计划(长期)
### 阶段 1已落地
- provider 归一化Vertex 默认 `google_location=global` 的回归保护
- SyncServiceRedis snapshot 写入与 routing key 生成
- request_idGin middleware 透传/生成
### 阶段 2已落地一部分
- Master/KeyCreateMaster/ValidateMasterKey/IssueChildKey 的关键分支(含 child key 上限)
待补齐:
- Master/Keyepoch/禁用等更多状态分支
- LogWriter批处理/刷盘边界(可用 fake clock 或缩短 flush interval
### 阶段 3已落地一部分契约测试
- 与 DP 的 provider snapshot schema 契约:`internal/service/testdata/provider_snapshot.json` + SyncProvider 输出回归
待扩展:
- model snapshot 契约能力字段、max_output_tokens 等)
- token/master snapshot 契约(如果后续引入更多字段)