67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package meituan_union
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
// api-单元测试
|
|
type apiClientSuite struct {
|
|
suite.Suite
|
|
api MeituanUnionApi
|
|
}
|
|
|
|
func TestApiClient(t *testing.T) {
|
|
suite.Run(t, new(apiClientSuite))
|
|
}
|
|
|
|
func (a *apiClientSuite) SetupSuite() {
|
|
log := logx.WithContext(context.Background())
|
|
apiClient := NewApiClient(log, AuthConfig{
|
|
AppKey: "8b0a6d711cd573b5b048c90820dbb3fe756",
|
|
SignKey: "3e4a697ecd9eafa27c2f3f4ccf22072d",
|
|
NotifyKey: "gb8cwkj53x",
|
|
})
|
|
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)
|
|
}
|
|
|
|
func (a *apiClientSuite) Test_GetOrderBySinge() {
|
|
req := GetOrderBySingeRequest{
|
|
ActId: 33,
|
|
OrderId: "3801047573041660994",
|
|
}
|
|
resp, err := a.api.GetOrderBySinge(req)
|
|
if !a.NoError(err) {
|
|
a.T().Error(err)
|
|
return
|
|
}
|
|
a.T().Logf("=====[Test_GetOrderBySinge] resp: %+v", resp)
|
|
}
|
|
|
|
func (a *apiClientSuite) Test_GetOrderByBatch() {
|
|
req := GetOrderByBatchRequest{
|
|
ActId: 33,
|
|
Page: 1,
|
|
Limit: 10,
|
|
StartTime: 1714147200,
|
|
EndTime: 1714233500,
|
|
}
|
|
list, err := a.api.GetOrderByBatch(req)
|
|
if !a.NoError(err) {
|
|
a.T().Errorf("========[Test_GetOrderByBatch] error:%s", err)
|
|
return
|
|
}
|
|
a.T().Logf("=====[Test_GetOrderByBatch] list: %+v", list)
|
|
}
|