third-platform-sdk/platform/tong-cheng/api_test.go
2024-07-14 22:14:27 +08:00

69 lines
1.6 KiB
Go

package tong_cheng
import (
"context"
"encoding/json"
"testing"
"github.com/stretchr/testify/suite"
"github.com/zeromicro/go-zero/core/logx"
)
// api-单元测试
type apiClientSuite struct {
suite.Suite
api TongChengApi
}
func TestApiClient(t *testing.T) {
suite.Run(t, new(apiClientSuite))
}
func (a *apiClientSuite) SetupSuite() {
log := logx.WithContext(context.Background())
apiClient := NewApiClient(log, AuthConfig{
Token: "dfae91a85341865b",
})
a.api = apiClient
}
func (a *apiClientSuite) Test_GenerateLink() {
req := GenerateLinkRequest{
Trackid: "elong_hotel",
}
result, err := a.api.GenerateLink(context.Background(), req, "huidu")
if !a.NoError(err) {
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
return
}
resultByte, err := json.Marshal(result)
if err != nil {
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
return
}
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
}
func (a *apiClientSuite) Test_QueryOrderList() {
req := QueryOrderListRequest{
AppId: "",
Trackid: "",
BeginDate: "2024-07-01 00:00:00",
EndDate: "2024-07-01 23:59:59",
Update: 1,
PageIndex: 0,
PageSize: 1,
}
result, err := a.api.QueryOrderList(context.Background(), req, "huidu")
if !a.NoError(err) {
a.T().Errorf("========[Test_QueryOrderList] response error:%s", err)
return
}
resultByte, err := json.Marshal(result)
if err != nil {
a.T().Errorf("========[Test_QueryOrderList] json_marshal error:%s", err)
return
}
a.T().Logf("=====[Test_QueryOrderList] result: %s", string(resultByte))
}