hyapp-server/docs/房内猜拳本地真实IM测试.md
2026-06-11 13:33:44 +08:00

48 lines
1.8 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.

# 房内猜拳本地真实 IM 测试
测试文件:`tests/smoke/room_rps_real_im_flow_test.go`
## 作用
- 用本地 gateway 真实 HTTP 接口跑房内猜拳流程。
- 通过 `/api/v1/auth/account/quick-create` 自动创建发起人和应战人。
- 用真实腾讯 IM REST 确保房间群、导入两个账号、发送一条 `TIMCustomElem` 探针消息。
- 不使用 fake client不伪造 access token不伪造 IM 成功。
## 前置
- 本地 gateway 地址默认:`http://127.0.0.1:13000/api/v1`
- 本地 gateway、game-service、user-service 已启动。
- game-service 启动时需要带 `TENCENT_IM_SDK_APP_ID``TENCENT_IM_SECRET_KEY``TENCENT_IM_ADMIN_IDENTIFIER`,这样创建和应战接口会真实投递 IM。
- 不传 `ROOM_RPS_ROOM_ID` 时,测试会自动创建 `room-rps-real-im-时间戳` 临时群。
- 不传 `ROOM_RPS_GIFT_ID` 时,使用默认已开启礼物 `10001`
- 腾讯 IM 配置必须和本地 gateway 使用同一个 SDKAppID。
## 命令
```bash
ROOM_RPS_REAL_IM_FLOW_TEST=1 \
ROOM_RPS_BASE_URL=http://127.0.0.1:13000/api/v1 \
ROOM_RPS_APP_CODE=lalu \
TENCENT_IM_SDK_APP_ID=1400000000 \
TENCENT_IM_SECRET_KEY='<secret_key>' \
TENCENT_IM_ADMIN_IDENTIFIER=administrator \
TENCENT_IM_ENDPOINT=adminapisgp.im.qcloud.com \
go test ./tests/smoke -run TestRoomRPSLocalHTTPFlowWithRealTencentIM -count=1 -v
```
## 返回判断
- 通过:本地 HTTP 流程完成,真实腾讯 IM 探针消息发送成功game-service 创建和应战 IM 投递成功,发起人和应战人返回头像昵称。
- 失败并提示腾讯 IM 错误:先检查 SDKAppID、SecretKey、管理员账号、endpoint 和 GroupID。
## 清理
默认会清理自动创建的 `room-rps-real-im-` 临时群。
如果传入真实房间群,不要开启清理;可以显式加:
```bash
ROOM_RPS_CLEANUP_IM_GROUP=0
```