third-platform-sdk/platform/jd-union/api_test.go
yanfan d3e3119c14 京东联盟
折淘客
2025-05-15 17:59:51 +08:00

71 lines
1.6 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 jd_union
import (
"context"
"encoding/json"
"fmt"
"testing"
"github.com/stretchr/testify/suite"
"github.com/zeromicro/go-zero/core/logx"
)
// api-单元测试
type apiClientSuite struct {
suite.Suite
api JdUnionApi
}
func TestApiClient(t *testing.T) {
suite.Run(t, new(apiClientSuite))
}
func (a *apiClientSuite) SetupSuite() {
log := logx.WithContext(context.Background())
apiClient := NewApiClient(log, AuthConfig{
AppKey: "",
AppSecret: "",
})
a.api = apiClient
}
func (a *apiClientSuite) Test_QueryOrderList() {
data := QueryOrderListRequest{
PageIndex: 1,
PageSize: 20,
Type: 1, //订单时间查询类型(1下单时间2完成时间购买用户确认收货时间3更新时间
StartTime: "2025-05-14 17:00:00",
EndTime: "2025-05-14 18:00:00",
}
resp, err := a.api.QueryOrderList(data)
if err != nil {
a.T().Errorf("=====[Test_QueryOrderList] err: %v", err)
}
if resp != nil {
a.T().Logf("=====[Test_QueryOrderList] resp: %+v, err: %v", resp, err)
if len(resp.Data) > 0 {
for _, v := range resp.Data {
va, _ := json.Marshal(v)
fmt.Println(string(va))
}
}
}
}
func (a *apiClientSuite) Test_PromotionLink() {
data := PromotionLinkRequest{
MaterialId: "https://u.jd.com/rDPUXnL",
SiteId: "",
PositionId: 100030093812,
}
resp, err := a.api.PromotionLink(data)
if err != nil {
a.T().Errorf("=====[Test_PromotionLink] err: %v", err)
}
a.T().Logf("=====[Test_PromotionLink] resp: %+v, err: %v", resp, err)
if resp != nil {
va, _ := json.Marshal(resp.Data)
fmt.Println(string(va))
}
}