third-platform-sdk/platform/zjdg/api_test.go

57 lines
1.2 KiB
Go
Raw Normal View History

2025-02-24 16:51:08 +08:00
package zjdg
import (
"context"
"encoding/json"
"github.com/stretchr/testify/suite"
"github.com/zeromicro/go-zero/core/logx"
"testing"
)
// api-单元测试
type apiClientSuite struct {
suite.Suite
api ZjdgApi
}
func TestApiClient(t *testing.T) {
suite.Run(t, new(apiClientSuite))
}
func (a *apiClientSuite) SetupSuite() {
log := logx.WithContext(context.Background())
apiClient := NewApiClient(log, AuthConfig{
UserId: "", //
})
a.api = apiClient
}
func (a *apiClientSuite) Test_ZoneAdd() {
req := ZoneAddRequest{}
2025-02-24 17:54:14 +08:00
result, err := a.api.ZoneAdd(context.Background(), req)
2025-02-24 16:51:08 +08:00
if !a.NoError(err) {
2025-02-24 18:13:25 +08:00
a.T().Errorf("========[Test_ZoneAdd] response error:%s", err)
2025-02-24 16:51:08 +08:00
return
}
resultByte, err := json.Marshal(result)
if err != nil {
2025-02-24 18:13:25 +08:00
a.T().Errorf("========[Test_ZoneAdd] json_marshal error:%s", err)
2025-02-24 16:51:08 +08:00
return
}
2025-02-24 18:13:25 +08:00
a.T().Logf("=====[Test_ZoneAdd] result: %s", string(resultByte))
}
func (a *apiClientSuite) Test_GenerateH5Url() {
req := GenerateH5UrlRequest{
ActivityUrl: PromotionUrl,
Sid: "1963667",
}
result, err := a.api.GenerateH5Url(context.Background(), req)
if !a.NoError(err) {
a.T().Errorf("========[Test_GenerateH5Url] response error:%s", err)
return
}
a.T().Logf("=====[Test_GenerateH5Url] result: %s", result)
2025-02-24 16:51:08 +08:00
}