246 lines
5.3 KiB
Go
246 lines
5.3 KiB
Go
package stat
|
||
|
||
import (
|
||
"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) {
|
||
req := CreateUserRegRequest()
|
||
|
||
// DeviceInfo 字段
|
||
req.Network = "WiFi"
|
||
req.ScreenResolution = "1920x1080"
|
||
req.System = "Android 11"
|
||
req.Electric = "80"
|
||
req.ProcessorModel = "Snapdragon 888"
|
||
req.BaseBand = "qualcomm"
|
||
req.Model = "Xiaomi Mi 11"
|
||
req.Battery = "80"
|
||
req.Package = "com.game.test"
|
||
req.LongId = "device_long_id_123456"
|
||
req.Imei = "123456789012345"
|
||
req.Oaid = "oaid_1234567890"
|
||
req.Idfa = "idfa_1234567890"
|
||
req.Idfv = "idfv_1234567890"
|
||
req.AdDevice = "ad_device_info"
|
||
req.Os = "Android"
|
||
req.IP = "192.168.1.100"
|
||
req.Ua = "Mozilla/5.0..."
|
||
req.WxPlatform = "WeChat MiniProgram"
|
||
req.Adinfo = "ad_info_data"
|
||
|
||
// UserRegRequest 特有字段
|
||
req.ChannelId = 1
|
||
req.GameId = 7275
|
||
req.LoginGameId = 7275
|
||
req.GameSign = "qwldy"
|
||
req.Uid = 123456
|
||
req.UserName = "test_user"
|
||
req.Openid = 123456
|
||
req.ComeBackUser = 1
|
||
req.RegTime = time.Now().Unix()
|
||
req.Logined = 1
|
||
req.RegType = 1
|
||
req.LpReg = 0
|
||
req.MatchType = 1
|
||
req.AgentId = 100
|
||
req.SiteId = 1001
|
||
req.PkgAgentId = 100
|
||
req.PkgSiteId = 1001
|
||
req.FromAd = 0
|
||
req.FanCode = "FAN123456"
|
||
req.InvalidUuid = 0
|
||
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) {
|
||
req := CreateUserLoginRequest()
|
||
// DeviceInfo 字段
|
||
req.Network = "WiFi"
|
||
req.ScreenResolution = "1920x1080"
|
||
req.System = "Android 11"
|
||
req.Electric = "80"
|
||
req.ProcessorModel = "Snapdragon 888"
|
||
req.BaseBand = "qualcomm"
|
||
req.Model = "Xiaomi Mi 11"
|
||
req.Battery = "80"
|
||
req.Package = "com.game.test"
|
||
req.LongId = "device_long_id_123456"
|
||
req.Imei = "123456789012345"
|
||
req.Oaid = "oaid_1234567890"
|
||
req.Idfa = "idfa_1234567890"
|
||
req.Idfv = "idfv_1234567890"
|
||
req.AdDevice = "ad_device_info"
|
||
req.Os = "Android"
|
||
req.IP = "192.168.1.100"
|
||
req.Ua = "Mozilla/5.0..."
|
||
req.WxPlatform = "WeChat MiniProgram"
|
||
req.Adinfo = "ad_info_data"
|
||
|
||
// UserRegRequest 特有字段
|
||
req.ChannelId = 1
|
||
req.GameId = 7275
|
||
req.GameSign = "qwldy"
|
||
req.Uid = 123456
|
||
req.UserName = "test_user"
|
||
req.RegTime = time.Now().Unix()
|
||
req.OriginalImei = req.Imei
|
||
req.LoginTime = time.Now().Unix()
|
||
req.LoginAgentId = 100
|
||
req.LoginSiteId = 1001
|
||
req.PkgAgentId = 100
|
||
req.PkgSiteId = 1001
|
||
req.Version = "2.7.1"
|
||
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)
|
||
}
|