third-platform-sdk/platform/t3-union/api_test.go
yanfan 4c4478dc84 取消api test秘钥信息
添加有票票渠道
2024-11-11 14:18:00 +08:00

121 lines
3.2 KiB
Go

package t3_union
import (
"context"
"encoding/json"
"testing"
"github.com/stretchr/testify/suite"
"github.com/zeromicro/go-zero/core/logx"
)
// api-单元测试
type apiClientSuite struct {
suite.Suite
api T3UnionApi
}
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_Sign() {
data := map[string]interface{}{
"name": "zhangsan",
"phone": "13800000001",
}
sign := a.api.Sign("POST", "/t3/union/test", data)
a.T().Logf("=====[TestSign] sign: %s", sign)
}
func (a *apiClientSuite) Test_GenerateLink() {
req := GenerateLinkRequest{
ActivityUuid: "c2873670644049da964c603a9a4e2a87",
SourceId: "yixiao",
SpotUuid: "1d444dbb3d6b475890dc9173f29fb66c",
LinkType: "WX",
}
result, err := a.api.GenerateLink(context.Background(), req)
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_GenerateCode() {
req := GenerateCodeRequest{
ActivityUuid: "c2873670644049da964c603a9a4e2a87",
SourceId: "yixiao",
SpotUuid: "1d444dbb3d6b475890dc9173f29fb66c",
Dsi: "6bc21eea27e341e994e8c998218be230",
Type: "WX",
}
result, err := a.api.GenerateCode(context.Background(), req)
if !a.NoError(err) {
a.T().Errorf("========[Test_GenerateCode] response error:%s", err)
return
}
resultByte, err := json.Marshal(result)
if err != nil {
a.T().Errorf("========[Test_GenerateCode] json_marshal error:%s", err)
return
}
a.T().Logf("=====[Test_GenerateCode] result: %s", string(resultByte))
}
func (a *apiClientSuite) Test_GeneratePoster() {
req := GeneratePosterRequest{
ActivityUuid: "c2873670644049da964c603a9a4e2a87",
SourceId: "yixiao",
SpotUuid: "1d444dbb3d6b475890dc9173f29fb66c",
Dsi: "6bc21eea27e341e994e8c998218be230",
}
result, err := a.api.GeneratePoster(context.Background(), req)
if !a.NoError(err) {
a.T().Errorf("========[Test_GeneratePoster] response error:%s", err)
return
}
resultByte, err := json.Marshal(result)
if err != nil {
a.T().Errorf("========[Test_GeneratePoster] json_marshal error:%s", err)
return
}
a.T().Logf("=====[Test_GeneratePoster] result: %s", string(resultByte))
}
func (a *apiClientSuite) Test_QueryOrderList() {
req := QueryOrderListRequest{
PageNo: 1,
PageSize: 1,
SupplierUuid: "13550119392",
StartTime: 1715702400000,
EndTime: 1718380800000,
}
result, err := a.api.QueryOrderList(context.Background(), req)
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))
}