test(game): 补充 GetKfUrl 请求参数直接断言,验证 uid 空值不下发
This commit is contained in:
parent
a6cc33fcc4
commit
8b692dd9af
@ -4,6 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetKfUrl(t *testing.T) {
|
func TestGetKfUrl(t *testing.T) {
|
||||||
@ -57,3 +59,26 @@ func TestGetKfUrlGuest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fmt.Println(resp.Code, resp.Msg, resp.Data.KfUrl)
|
fmt.Println(resp.Code, resp.Msg, resp.Data.KfUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestGetKfUrlReqParams 直接断言请求参数:不设 Uid 时 JsonParams 里不应出现 "uid" key,
|
||||||
|
// 设了 Uid 时应正确出现,避免只靠服务端返回的 kf_url 做间接验证。
|
||||||
|
func TestGetKfUrlReqParams(t *testing.T) {
|
||||||
|
guestReq := CreateGetKfUrlReq()
|
||||||
|
guestReq.GameId = 10003
|
||||||
|
if err := requests.InitParam(guestReq); err != nil {
|
||||||
|
t.Fatalf("InitParam err: %v", err)
|
||||||
|
}
|
||||||
|
if _, ok := guestReq.JsonParams["uid"]; ok {
|
||||||
|
t.Fatalf("游客请求不应包含 uid 参数: %v", guestReq.JsonParams["uid"])
|
||||||
|
}
|
||||||
|
|
||||||
|
userReq := CreateGetKfUrlReq()
|
||||||
|
userReq.GameId = 10001
|
||||||
|
userReq.Uid = "166146"
|
||||||
|
if err := requests.InitParam(userReq); err != nil {
|
||||||
|
t.Fatalf("InitParam err: %v", err)
|
||||||
|
}
|
||||||
|
if userReq.JsonParams["uid"] != "166146" {
|
||||||
|
t.Fatalf("expect uid=166146, got %v", userReq.JsonParams["uid"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user