2024-05-13 23:18:54 +08:00
|
|
|
package didi_union
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"testing"
|
2024-05-15 22:01:40 +08:00
|
|
|
"time"
|
2024-05-13 23:18:54 +08:00
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
2024-05-15 22:01:40 +08:00
|
|
|
|
|
|
|
|
"gitee.com/chengdu-lenntc/third-platform-sdk/sdk/dunion-go-sdk/model"
|
2024-05-13 23:18:54 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// api-单元测试
|
|
|
|
|
type apiClientSuite struct {
|
|
|
|
|
suite.Suite
|
|
|
|
|
api DidiUnionApi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestApiClient(t *testing.T) {
|
|
|
|
|
suite.Run(t, new(apiClientSuite))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *apiClientSuite) SetupSuite() {
|
|
|
|
|
log := logx.WithContext(context.Background())
|
|
|
|
|
apiClient := NewApiClient(log, AuthConfig{
|
|
|
|
|
AppKey: "2M0QUa0o6ER8nuX1",
|
|
|
|
|
AppSecret: "obvJ5mmV45ZWA3YpO95njR1xH62JT50h",
|
|
|
|
|
})
|
|
|
|
|
a.api = apiClient
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *apiClientSuite) Test_Sign() {
|
|
|
|
|
data := map[string]interface{}{
|
|
|
|
|
"method": "test",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sign := a.api.Sign(data)
|
|
|
|
|
a.T().Logf("=====[TestSign] sign: %s", sign)
|
|
|
|
|
}
|
2024-05-15 22:01:40 +08:00
|
|
|
|
|
|
|
|
func (a *apiClientSuite) Test_GenerateH5Link() {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
req := GenerateLinkRequest{
|
|
|
|
|
ActivityID: 207811824611,
|
|
|
|
|
PromotionID: 7193964476899539205,
|
|
|
|
|
SourceID: "test",
|
|
|
|
|
}
|
|
|
|
|
opt := model.Option{
|
|
|
|
|
Timeout: time.Second * 10,
|
|
|
|
|
}
|
|
|
|
|
resp, err := a.api.GenerateH5Link(ctx, req, opt)
|
|
|
|
|
if !a.NoError(err) {
|
|
|
|
|
a.T().Errorf("=====[TestGenerateH5Link] err: %v", err)
|
|
|
|
|
}
|
|
|
|
|
a.T().Logf("=====[TestGenerateH5Link] resp: %+v, err: %v", resp, err)
|
|
|
|
|
}
|
2024-06-25 17:01:52 +08:00
|
|
|
|
|
|
|
|
func (a *apiClientSuite) Test_QueryOrderList() {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
req := QueryOrderListRequest{
|
|
|
|
|
Page: 1,
|
|
|
|
|
Size: 100,
|
|
|
|
|
StartTime: time.Unix(1714492800, 0),
|
|
|
|
|
EndTime: time.Unix(1717171199, 0),
|
|
|
|
|
}
|
|
|
|
|
opt := model.Option{
|
|
|
|
|
Timeout: time.Second * 10,
|
|
|
|
|
}
|
|
|
|
|
resp, err := a.api.QueryOrderList(ctx, req, opt)
|
|
|
|
|
if !a.NoError(err) {
|
|
|
|
|
a.T().Errorf("=====[TestGenerateH5Link] err: %v", err)
|
|
|
|
|
}
|
|
|
|
|
a.T().Logf("=====[TestGenerateH5Link] resp: %+v, err: %v", resp, err)
|
|
|
|
|
}
|