47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
|
|
package yapingtech
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
"github.com/stretchr/testify/suite"
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
// api-单元测试
|
||
|
|
type apiClientSuite struct {
|
||
|
|
suite.Suite
|
||
|
|
api YaPingTechApi
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestApiClient(t *testing.T) {
|
||
|
|
suite.Run(t, new(apiClientSuite))
|
||
|
|
}
|
||
|
|
|
||
|
|
func (a *apiClientSuite) SetupSuite() {
|
||
|
|
log := logx.WithContext(context.Background())
|
||
|
|
apiClient := NewApiClient(log, AuthConfig{
|
||
|
|
AppId: "ov595MzFifkk1usgIx3+3Q==",
|
||
|
|
AppSecret: "8/3eQzZbj9ymbC80MHm1EgcMZ1wUI2wOrxjwx4dfiekG/u+wvW3lqz6PKnzYQ0Hs",
|
||
|
|
})
|
||
|
|
a.api = apiClient
|
||
|
|
}
|
||
|
|
|
||
|
|
func (a *apiClientSuite) Test_QueryOrderList() {
|
||
|
|
req := QueryOrderListRequest{
|
||
|
|
Page: 1,
|
||
|
|
OutOrderSn: "Y02141445536174133",
|
||
|
|
}
|
||
|
|
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))
|
||
|
|
}
|