test(listing): 覆盖最新外部上传格式映射

This commit is contained in:
yml
2026-11-22 16:24:36 +08:00
parent 6fcd5bac9c
commit 6ea73fb4a6
@@ -81,3 +81,74 @@ func TestExternalAccountToCreateRequestFollowsPublishOptions(t *testing.T) {
t.Fatalf("消耗品折算价 = %v, want 7.9", got) t.Fatalf("消耗品折算价 = %v, want 7.9", got)
} }
} }
func TestExternalAccountToCreateRequestSupportsLatestUploadFormat(t *testing.T) {
req := externalAccountToCreateRequest("客服1", 0, ExternalAccountData{
LoginMethod: "QQ账号密码",
Rank: "巅峰",
Level: 60,
SafeSlots: 9,
SecretKD: 0.2,
DailyLossM: 10,
Deposit: 150,
BanRecord: "有",
CommonRegion: "四川省德阳市",
ContactPhone: "15196354603",
OwnerOnlineTime: "07:00 至 22:00",
Remark: "点券和砖不能动\n封禁历史:2026/11/02 语音封禁半小时2026/08/24语音封禁半小时",
Currency: ExternalUploadCurrency{
HafuCoin: 108,
RecycleRatio: 47,
RecycleRent: 230,
},
DailyConsumption: ExternalDailyConsumption{Stamina: 7, Weight: 7},
Inventory: ExternalUploadInventory{
AWMBullets: 191,
Level6Helmets: 12,
Level6Armor: 15,
Skins: []string{
"坠星者",
"无名-夜鹰",
"威龙-吴彦祖",
"疾风-西部往事",
"骇爪-骇客少女",
},
},
}, defaultSalePriceConfig(), systemconfig.DefaultPublishOptions())
if req.ServerRegion != "QQ" || req.LoginPlatform != "QQ账号密码" {
t.Fatalf("登录方式映射不正确: %q/%q", req.ServerRegion, req.LoginPlatform)
}
if req.HafCoinAmount != 108000000 || req.DepositAmountCent != 15000 {
t.Fatalf("币数或押金映射不正确: %d/%d", req.HafCoinAmount, req.DepositAmountCent)
}
if req.Description != "点券和砖不能动\n封禁历史:2026/11/02 语音封禁半小时2026/08/24语音封禁半小时" {
t.Fatalf("Description = %q", req.Description)
}
if req.AssetSummary["common_regions"] == nil ||
req.AssetSummary["online_time_text"] != "07:00 至 22:00" ||
req.AssetSummary["ban_record"] != "有封禁记录" {
t.Fatalf("资产快照映射不完整: %#v", req.AssetSummary)
}
groups := req.AssetSummary["skin_groups"].(map[string][]string)
skinCount := 0
for _, skins := range groups {
skinCount += len(skins)
}
if skinCount != 5 {
t.Fatalf("皮肤未完整写入: %#v", groups)
}
resources := req.AssetSummary["resources"].([]any)
quantities := map[string]int{}
for _, raw := range resources {
row := raw.(map[string]any)
key, _ := row["key"].(string)
quantity, _ := row["quantity"].(int)
quantities[key] = quantity
}
if quantities["awmAmmo"] != 191 || quantities["helmet6"] != 12 || quantities["armor6"] != 15 {
t.Fatalf("装备数量未完整写入: %#v", quantities)
}
}