88 lines
2.0 KiB
Go
88 lines
2.0 KiB
Go
package botser
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/url"
|
|
"os"
|
|
"stat/api/proto"
|
|
"stat/common"
|
|
"stat/common/crypt"
|
|
"stat/common/utils"
|
|
"stat/tool/pubtest"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func Test_Func12(t *testing.T) {
|
|
// Let's start with a base url
|
|
baseUrl, err := url.Parse("http://www.bing.com/aaa?a=1&b=2,3")
|
|
if err != nil {
|
|
fmt.Println("Malformed URL: ", err.Error())
|
|
return
|
|
}
|
|
// Add a Path Segment (Path segment is automatically escaped)
|
|
//baseUrl.Path += "path with?reserved characters"
|
|
// Prepare Query Parameters
|
|
params := baseUrl.Query()
|
|
//params.Add("q", "Hello World")
|
|
//params.Add("u", "wade")
|
|
// Add Query Parameters to the URL
|
|
baseUrl.RawQuery = params.Encode() // Escape Query Parameters
|
|
fmt.Printf("Encoded URL is %q\n", baseUrl.String())
|
|
}
|
|
|
|
func Test_SyncData(t *testing.T) {
|
|
key := "vEnkB&!75z4VAD6iAY%fkL*rBnU!WdhN"
|
|
var appId int32 = 222
|
|
|
|
req := &proto.BotDailyHourListReq{
|
|
Page: common.Page{
|
|
PageNum: 1,
|
|
PageSize: 20,
|
|
},
|
|
SumDateStart: time.Now().AddDate(0, 0, -3),
|
|
SumDateStop: time.Now(),
|
|
AppId: &appId,
|
|
}
|
|
jsonData, err := json.Marshal(req)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
data, err := crypt.CoreAesEncryptEx(jsonData, 12, key)
|
|
os.WriteFile("aaa.data", data, 777)
|
|
|
|
}
|
|
|
|
func Test_skdTask(t *testing.T) {
|
|
pubtest.TestInit("/Users/mac/Works/codes/stat_center/run/bili")
|
|
s, _ := time.Parse(time.RFC3339, "2023-06-15T15:00:00+08:00")
|
|
curStatTime := utils.RecentMinute(s, 60) // 按60分钟对齐
|
|
ctx := context.Background()
|
|
DailyBotReportTask(ctx, nil, int32(444), curStatTime) // 麻豆
|
|
}
|
|
|
|
func Test_PassedTimeFromNowInHuman(t *testing.T) {
|
|
//s := PassedTimeFromNowInHuman(time.Now().Add(-9 * time.Minute))
|
|
//t.Log(s)
|
|
//s2 := DurationDisplay(time.Now(), time.Now().Add(-8*time.Second))
|
|
//t.Log(s2)
|
|
}
|
|
|
|
func Test_Fun1(t *testing.T) {
|
|
time.Local, _ = time.LoadLocation("Asia/Shanghai")
|
|
|
|
//DateTime = "2006-01-02 15:04:05"
|
|
//DateOnly = "2006-01-02"
|
|
//TimeOnly = "15:04:05"
|
|
|
|
s, err := time.ParseInLocation(time.DateOnly, "2023-06-15", time.Local)
|
|
if err != nil {
|
|
t.Error(err)
|
|
} else {
|
|
t.Log(s)
|
|
}
|
|
}
|