255 lines
5.6 KiB
Go
255 lines
5.6 KiB
Go
package stat
|
||
|
||
import (
|
||
"encoding/json"
|
||
"fmt"
|
||
"testing"
|
||
"time"
|
||
)
|
||
|
||
func TestSyncGameServerList(t *testing.T) {
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
req := CreateSyncGameServerListReq("insertOrUpdate", []map[string]interface{}{
|
||
{
|
||
"id": 123564,
|
||
"channel_id": 12456,
|
||
"version_id": 1,
|
||
"game_id": 1,
|
||
"server_id": 1,
|
||
"game_sign": "test",
|
||
"name": "test",
|
||
"open_date": "2099-03-01",
|
||
"open_time": "12:00:00",
|
||
"remark": "",
|
||
"status": 1,
|
||
"if_tj": 1,
|
||
},
|
||
})
|
||
|
||
resp, err := client.SyncGameServerList(req)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
|
||
fmt.Println(resp.Code, resp.Msg, resp.Count)
|
||
}
|
||
|
||
func TestClient_SetUserNewGameAuth(t *testing.T) {
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
req := CreateSetUserNewGameAuthReq(map[string]string{
|
||
"game_sign": "qwldy",
|
||
"game_id": "7275",
|
||
})
|
||
|
||
resp, err := client.SetUserNewGameAuth(req)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
|
||
fmt.Println(resp.Code, resp.Msg, resp.Data.Result)
|
||
}
|
||
|
||
// TestClient_GetAgentList 查询代理列表单元测试
|
||
func TestClient_GetAgentList(t *testing.T) {
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
req := CreateGetAgentListReq(map[string]string{
|
||
"agent_id": "4051,68017",
|
||
//"agent_id": "99",
|
||
})
|
||
|
||
resp, err := client.GetAgentList(req)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
|
||
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
||
|
||
// 断言 resp.Code = 1,且 resp.Data 不空为正常
|
||
if resp.Code != 1 || len(resp.Data.List) == 0 {
|
||
t.Errorf("GetAgentList test failed")
|
||
} else {
|
||
t.Log("GetAgentList test passed")
|
||
}
|
||
}
|
||
|
||
// TestClient_GetUserRoleRegPage 查询用户角色注册分页
|
||
func TestClient_GetUserRoleRegPage(t *testing.T) {
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
req := CreateUserRoleRegPageReq(UserRoleRegParam{
|
||
Page: 1,
|
||
PageSize: 10,
|
||
RoleId: "",
|
||
RoleName: "温文波箐魔灵",
|
||
})
|
||
|
||
resp, err := client.GetUserRoleRegPage(req)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
||
}
|
||
|
||
// 获取用户累计付费
|
||
func TestGetUserTotalPay(t *testing.T) {
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
req := CreateGetUserTotalPayReq(GetUserTotalPayParam{
|
||
Where: "user_name = 'yoyo685757'",
|
||
Fields: []string{"user_name", "sum(total_pay_money) as total_pay_money", "last_pay_time"},
|
||
GroupBy: []string{"user_name"},
|
||
})
|
||
|
||
resp, err := client.GetUserTotalPay(req)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
||
}
|
||
|
||
func TestGetGameServerCountData(t *testing.T) {
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
req := CreateGetGameServerCountDataReq(&GetGameServerCountDataReq{
|
||
GameIds: []int64{3706},
|
||
ServerId: 203902,
|
||
RoleDates: []string{"2023-10-09", "2024-02-06"},
|
||
})
|
||
resp, err := client.GetGameServerCountData(req)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
|
||
fmt.Printf("%+v", resp.Data)
|
||
}
|
||
|
||
func TestUserReg(t *testing.T) {
|
||
|
||
param := &UserRegParam{}
|
||
// DeviceInfo 字段
|
||
param.Network = "WiFi"
|
||
param.ScreenResolution = "1920x1080"
|
||
param.System = "Android 11"
|
||
param.Electric = "80"
|
||
param.ProcessorModel = "Snapdragon 888"
|
||
param.BaseBand = "qualcomm"
|
||
param.Model = "Xiaomi Mi 11"
|
||
param.Battery = "80"
|
||
param.Package = "com.game.test"
|
||
param.LongId = "device_long_id_123456"
|
||
param.Imei = "123456789012345"
|
||
param.Oaid = "oaid_1234567890"
|
||
param.Idfa = "idfa_1234567890"
|
||
param.Idfv = "idfv_1234567890"
|
||
param.AdDevice = "ad_device_info"
|
||
param.Os = "Android"
|
||
param.IP = "192.168.1.100"
|
||
param.Ua = "Mozilla/5.0..."
|
||
param.WxPlatform = "WeChat MiniProgram"
|
||
param.Adinfo = "ad_info_data"
|
||
|
||
// UserRegparamuest 特有字段
|
||
param.ChannelId = 1
|
||
param.GameId = 7275
|
||
param.LoginGameId = 7275
|
||
param.GameSign = "qwldy"
|
||
param.Uid = 123456
|
||
param.UserName = "test_user"
|
||
param.Openid = "123456"
|
||
param.ComeBackUser = 1
|
||
param.RegTime = time.Now().Unix()
|
||
param.Logined = 1
|
||
param.RegType = 1
|
||
param.LpReg = 0
|
||
param.MatchType = 1
|
||
param.AgentId = 100
|
||
param.SiteId = 1001
|
||
param.PkgAgentId = 100
|
||
param.PkgSiteId = 1001
|
||
param.FromAd = 0
|
||
param.FanCode = "FAN123456"
|
||
param.InvalidUuid = 0
|
||
req := CreateUserRegRequest(param)
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
resp, err := client.UserReg(req)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
|
||
t.Log(resp.Code)
|
||
}
|
||
|
||
func TestUserLogin(t *testing.T) {
|
||
param := &UserLoginParam{}
|
||
// DeviceInfo 字段
|
||
param.Network = "WiFi"
|
||
param.ScreenResolution = "1920x1080"
|
||
param.System = "Android 11"
|
||
param.Electric = "80"
|
||
param.ProcessorModel = "Snapdragon 888"
|
||
param.BaseBand = "qualcomm"
|
||
param.Model = "Xiaomi Mi 11"
|
||
param.Battery = "80"
|
||
param.Package = "com.game.test"
|
||
param.LongId = "device_long_id_123456"
|
||
param.Imei = "123456789012345"
|
||
param.Oaid = "oaid_1234567890"
|
||
param.Idfa = "idfa_1234567890"
|
||
param.Idfv = "idfv_1234567890"
|
||
param.AdDevice = "ad_device_info"
|
||
param.Os = "Android"
|
||
param.IP = "192.168.1.100"
|
||
param.Ua = "Mozilla/5.0..."
|
||
param.WxPlatform = "WeChat MiniProgram"
|
||
param.Adinfo = "ad_info_data"
|
||
|
||
// UserRegparamuest 特有字段
|
||
param.ChannelId = 1
|
||
param.GameId = 7275
|
||
param.GameSign = "qwldy"
|
||
param.Uid = 123456
|
||
param.UserName = "test_user"
|
||
param.RegTime = time.Now().Unix()
|
||
param.OriginalImei = param.Imei
|
||
param.LoginTime = time.Now().Unix()
|
||
param.LoginAgentId = 100
|
||
param.LoginSiteId = 1001
|
||
param.PkgAgentId = 100
|
||
param.PkgSiteId = 1001
|
||
param.Version = "2.7.1"
|
||
b, err := json.Marshal(param)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
t.Log(string(b))
|
||
req := CreateUserLoginRequest(param)
|
||
client, err := NewClient()
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
|
||
resp, err := client.UserLogin(req)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
t.Log(resp.Code, resp.Data)
|
||
}
|