65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package jutuike
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"github.com/stretchr/testify/suite"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"testing"
|
|
)
|
|
|
|
// api-单元测试
|
|
type apiClientSuite struct {
|
|
suite.Suite
|
|
api JutuikeApi
|
|
}
|
|
|
|
func TestApiClient(t *testing.T) {
|
|
suite.Run(t, new(apiClientSuite))
|
|
}
|
|
|
|
func (a *apiClientSuite) SetupSuite() {
|
|
log := logx.WithContext(context.Background())
|
|
apiClient := NewApiClient(log, AuthConfig{
|
|
ApiKey: "", //
|
|
})
|
|
a.api = apiClient
|
|
}
|
|
|
|
func (a *apiClientSuite) Test_GenerateLink() {
|
|
req := GenerateLinkRequest{
|
|
ActId: 60,
|
|
Sid: "10001zdt100034",
|
|
}
|
|
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_QueryOrderList() {
|
|
req := QueryOrderListRequest{
|
|
StartTime: "2024-11-05 14:16:07",
|
|
EndTime: "2024-11-05 14:26:07",
|
|
PageSize: 1,
|
|
}
|
|
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))
|
|
}
|