39 lines
914 B
Go
39 lines
914 B
Go
package l_short_utl_request
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
var access = "eW10OjkxMmU3MWE2NGI3ZjkzNzlkYWRkNWYzMzRhM2M3MjM2OTdiNjJmOTJkMThkZDY3NTNjZWI1MzMwOWIwNjE2NDg="
|
|
|
|
func TestBatchCreate(t *testing.T) {
|
|
in := &ShortUrlBatchCreate{
|
|
BatchName: "test_query_" + time.Now().Format("20060102150405"),
|
|
Urls: []string{
|
|
"https://www.baidu.com",
|
|
"https://github.com/trending",
|
|
"https://www.sojson.com/",
|
|
},
|
|
StartTimeStr: time.Now().Format(time.DateOnly),
|
|
EndTimeStr: time.Now().AddDate(0, 0, 2).Format(time.DateOnly),
|
|
WithBatchMap: true,
|
|
}
|
|
res, err := NewClient(WithAuth(access)).BatchCreate(in)
|
|
t.Log(res, err)
|
|
}
|
|
|
|
func TestBatchQuery(t *testing.T) {
|
|
// 查询批次
|
|
queryIn := &BatchQueryReq{
|
|
BatchNo: 4233953069,
|
|
}
|
|
|
|
queryRes, err := NewClient(WithAuth(access)).BatchQuery(queryIn)
|
|
if err != nil {
|
|
t.Errorf("BatchQuery failed: %v", err)
|
|
}
|
|
|
|
t.Logf("Query Response: %+v", queryRes)
|
|
}
|