third-platform-sdk/platform/shoutu-show/api_test.go

67 lines
1.7 KiB
Go
Raw Normal View History

2024-11-21 15:50:04 +08:00
package shoutu_show
import (
"context"
"encoding/json"
"github.com/stretchr/testify/suite"
"github.com/zeromicro/go-zero/core/logx"
"testing"
)
// api-单元测试
type apiClientSuite struct {
suite.Suite
api ShouTuShowApi
}
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_GenerateLink() {
req := GenerateLinkRequest{
2024-11-21 16:11:10 +08:00
ActivityUrl: "https://cms.zhongdiantui.com/#/pages/toMiniProgram/toMiniProgram",
2024-11-21 15:50:04 +08:00
Sid: "f3a8c1",
2024-11-21 16:11:10 +08:00
LinkCode: "aaakfhkahfkadk",
ActId: "1111",
2024-11-21 15:50:04 +08:00
}
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))
}
2024-11-21 16:11:10 +08:00
func (a *apiClientSuite) Test_GenerateWechatUrl() {
req := GenerateLinkRequest{
ActivityUrl: "pages/index/index?distributorId=VCiCWwU2&subChannelId=",
Sid: "f3a8c1",
}
result, err := a.api.GenerateWechatUrl(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))
}