test(integration): reorganize test structure and add runner script

- Move integration tests and mock upstream resources from `integration/` to `test/` directory.
- Add `test/integration.sh` script to orchestrate environment setup and test execution.
- Update build context in `docker-compose.integration.yml` to match new structure.
- Add documentation for local development and integration testing workflows in README.
This commit is contained in:
zenfun
2025-12-02 15:56:17 +08:00
parent a0f13d55c1
commit d147f3ab04
8 changed files with 41 additions and 1 deletions

View File

@@ -55,6 +55,26 @@ docker build -t ez-api .
docker run -p 8080:8080 --env-file .env ez-api
```
### 本地联合开发(配合 balancer
- 目录结构建议:`/workspace/` 下并列放置 `ez-api``balancer`
- 初始化/更新 Go 工作区Go 1.20+):在 `/workspace` 执行
```bash
go work use ./ez-api ./ez-api/test ./balancer
```
仓库已附带 `go.work`,若路径一致可直接复用;若放在其他位置请按上面命令重建。
### 集成测试
依赖 Docker 与 docker compose且默认在工作区里与 `balancer` 仓库并列(用于构建镜像)。在仓库内运行:
```bash
cd ez-api
./test/integration.sh
```
脚本会拉起 `docker-compose.integration.yml` 中的服务,运行带 `integration` tag 的 Go 测试,并在完成后清理容器和卷。
## 设计决策
- **异步日志**: 日志不会立即写入 DB。它们被缓冲在内存中并分批刷新以减少 DB IOPS。