71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
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))
|
||
}
|
||
}
|