test(expiry): 完成 #32 接口集成测试资产

This commit is contained in:
root
2026-03-04 18:37:45 +08:00
parent 6c303abd58
commit 3668b10be3
4 changed files with 314 additions and 0 deletions
@@ -0,0 +1,33 @@
# 保质期接口集成测试报告(2026-03-04)
## 范围
- 登录获取 Token`/api/v1/auth/login`
- 物品接口:创建、列表、汇总、更新、状态标记、删除
- 设置接口:获取与更新
## 测试资产
- Postman Collection: `docs/expiry/tests/postman/expiry.postman_collection.json`
- Postman Environment: `docs/expiry/tests/postman/expiry.postman_environment.json`
- 一键脚本: `scripts/expiry/run_integration_tests.sh`
## 执行方式
```bash
# 方式一:已有 token
BASE_URL=http://127.0.0.1:8080 TOKEN=<session_key> scripts/expiry/run_integration_tests.sh
# 方式二:通过 wx.login 的 code 登录
BASE_URL=http://127.0.0.1:8080 MINI_PROGRAM_ID=1 WX_CODE=<wx_code> scripts/expiry/run_integration_tests.sh
```
## 断言规则
- 登录接口:`HTTP 200 && code == 200`
- 业务接口:`HTTP 200 && code == 0`
- 错误接口:预期返回 4xx/5xx 与对应 message
## 性能测试建议
脚本内置 `hey` 调用(若系统已安装):
```bash
hey -n 100 -c 20 -H "Authorization: Bearer <token>" http://127.0.0.1:8080/api/expiry/summary
```
目标:平均响应时间 < 200ms(开发环境仅作参考,生产环境需复测)。