test: add comprehensive unit tests for provider, middleware, and sync service

- Add TESTING.md documentation explaining unit test conventions and integration testing setup
- Add miniredis and sqlite dependencies to go.mod for in-memory testing
- Add provider_handler_test.go ensuring Vertex providers default google_location to "global"
- Add request_id_test.go verifying request ID generation and header preservation
- Add sync_test.go validating Redis snapshot writes and routing key generation
- Update README.md with testing section referencing new documentation
This commit is contained in:
zenfun
2025-12-14 00:35:35 +08:00
parent 50da2ff668
commit d0011f3eb2
7 changed files with 279 additions and 0 deletions

View File

@@ -95,6 +95,10 @@ cd ez-api
脚本会拉起 `docker-compose.integration.yml` 中的服务,运行带 `integration` tag 的 Go 测试,并在完成后清理容器和卷。
## 测试
- 单元测试:`go test ./...`(测试文件与源码同目录,更多约定见 `TESTING.md`
## 日志
- 业务代码统一使用标准库 `log/slog``logger.Info("msg", "k", v)` 风格)。