44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package chat
|
||
|
||
import (
|
||
"fmt"
|
||
"testing"
|
||
)
|
||
|
||
// TestQueryChatRecords 集成测试:真实调用 chat.gaore.com 的 /api/internal/chatRecords。
|
||
//
|
||
// 运行前请确认:
|
||
// - chat 服务已部署本接口(InternalController::chatRecords)且网络可达;
|
||
// - 按需替换下面的 gr_uid / 时间范围为有数据的样本。
|
||
//
|
||
// 运行:go test ./services/chat/ -run TestQueryChatRecords -v
|
||
func TestQueryChatRecords(t *testing.T) {
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
t.Fatalf("NewClient: %v", err)
|
||
}
|
||
|
||
req := CreateQueryChatRecordsRequest(QueryChatRecordsParams{
|
||
GrUid: "188549603", // TODO: 换成有聊天记录的高热 uid
|
||
DateStart: "2026-07-01 00:00:00", // TODO: 换成实际时间范围
|
||
DateEnd: "2026-07-17 23:59:59",
|
||
Page: 1,
|
||
PageSize: 5,
|
||
})
|
||
|
||
resp, err := client.QueryChatRecords(req)
|
||
if err != nil {
|
||
t.Fatalf("QueryChatRecords: %v", err)
|
||
}
|
||
|
||
fmt.Printf("code=%d msg=%s total=%d 返回条数=%d\n",
|
||
resp.Code, resp.Msg, resp.Data.Total, len(resp.Data.Items))
|
||
for i, item := range resp.Data.Items {
|
||
fmt.Printf(" [%d] %+v\n", i, item)
|
||
}
|
||
|
||
if resp.Code != 1 {
|
||
t.Errorf("接口返回非成功:code=%d msg=%s", resp.Code, resp.Msg)
|
||
}
|
||
}
|