admin_backend/unit_test.go
2026-01-19 18:53:24 +08:00

152 lines
3.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"backend/Type"
"backend/alibaba"
"backend/feishu"
"backend/model"
"backend/sdk/ship/model/tuyou"
"backend/util"
"fmt"
"testing"
"time"
)
func TestXxx1(t *testing.T) {
//util.Statistics(0)
//feishu.SendOperationMsg2(0)
a := tuyou.ChargeRequest{
ApiVer: "2",
AppID: "20659",
AppInfo: `{"appId":1,"serverId":1,"orderId":"order_100100013_202511251228396eCumW","uid":100100013}`,
ChargedDiamonds: "20",
ChargedRmbs: "1.99",
ClientID: "Android_5.00_tyGuest,facebook.googleplay.0-hall20659.googleplay.Meowment",
ConsumeCoin: "20",
ConsumeID: "d50b32511250000110",
OrderID: "-",
PlatformOrder: "e50b32511250000549",
ProdCount: "1",
ProdID: "TY206590059",
ProdPrice: "1.99",
UserID: "19263",
Code: "385188b30e2924042c7ca30e3db818d7",
}
sign := a.Sign()
fmt.Println("sign:", sign)
if sign != "385188b30e2924042c7ca30e3db818d7" {
fmt.Println("签名错误")
} else {
fmt.Println("签名正确")
}
}
func TestXxx(t *testing.T) {
statistics := model.Statistics{}
statistics.AppId = 1
statistics.Emit = []string{"A"}
statistics.StatisticsOrder()
//controller.FeishuSendInfo2(nil)
// util.GetOrderData(3)
}
func TestFeishu(t *testing.T) {
data := struct {
Title string
Subtitle string
Elements string
}{
Title: "模拟测试",
Subtitle: "模拟测试副标题",
Elements: "",
}
s := util.ParseTmpl("./template/card.tmpl", data)
fmt.Println(s)
}
func TestFeishu2(t *testing.T) {
r := Type.NotifyData{}
err := feishu.SendNotifyMsg(&r)
if err != nil {
fmt.Println(err)
}
}
func TestLogin(t *testing.T) {
feishu.SendNotifyMsg(&Type.NotifyData{
NotifyMsg: "登录验证失败",
Host: "途游",
EventName: "invalid token",
Severity: "High",
AlarmTime: time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05"),
})
// Port, Host, ServerId := util.GetUserInfo(1, 156, "test", "test")
// fmt.Printf("ServerId:%d, Host:%s, Port:%d\n", ServerId, Host, Port)
}
func TestEncrypt(t *testing.T) {
str := "usSdkMysql*1133"
enc, _ := util.Encrypt(str)
fmt.Println(enc)
}
func TestDecrypt(t *testing.T) {
str := "Z4rf7eZZe500dxa"
enc, _ := util.Encrypt(str)
dec, _ := util.Decrypt("pUf9tft9GOPjV1z855Jf2DpB5NUpGEc_")
fmt.Printf("enc:%s\ndec:%s\n", enc, dec)
}
func TestAlibaba(t *testing.T) {
//err := alibaba.CreateSpace()
version := alibaba.DownloadFile()
fmt.Println("version:", version)
}
func TestAlibabaRobot(t *testing.T) {
title := "【meowment】订单发货成功"
content := `
- 玩家账号test_user_001
- 玩家等级25
- 订单号e50b32601160423c7f
- 金额 1.99
- 发货时间2026-01-15 18:22:12
- 充值总数10.99 元
[鼓掌][鼓掌][鼓掌]
`
err := alibaba.SendStandardMsg(title, content, "green")
if err != nil {
fmt.Println("err:", err)
} else {
fmt.Println("消息发送成功")
}
}
func TestAlibabaCard(t *testing.T) {
r := Type.NotifyData{
NotifyMsg: "测试报警消息内容",
Host: "测试主机",
EventName: "测试事件名称",
Severity: "High",
AlarmTime: time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05"),
}
err := alibaba.SendZabbixMsg(&r)
if err != nil {
fmt.Println("err:", err)
} else {
fmt.Println("卡片发送成功")
}
}
func TestServerUpdateApp(t *testing.T) {
}
func TestXxxx(t *testing.T) {
util.SaveGitHead("src", "7d6a040cec2841c728fc798d720bac30c5084ceb")
}