third-platform-sdk/platform/elong-hotel/api_test.go

96 lines
2.8 KiB
Go
Raw Permalink Normal View History

2024-07-17 22:10:35 +08:00
package elong_hotel
2024-07-14 22:14:27 +08:00
import (
"context"
"encoding/json"
"testing"
"github.com/stretchr/testify/suite"
"github.com/zeromicro/go-zero/core/logx"
)
// api-单元测试
type apiClientSuite struct {
suite.Suite
2024-07-17 22:10:35 +08:00
api ElongHotelApi
2024-07-14 22:14:27 +08:00
}
func TestApiClient(t *testing.T) {
suite.Run(t, new(apiClientSuite))
}
func (a *apiClientSuite) SetupSuite() {
log := logx.WithContext(context.Background())
apiClient := NewApiClient(log, AuthConfig{
Token: "",
2024-07-14 22:14:27 +08:00
})
a.api = apiClient
}
func (a *apiClientSuite) Test_GenerateLink() {
2024-07-15 23:11:04 +08:00
req := GetExternalChannelConfigRequest{
2024-07-14 22:14:27 +08:00
Trackid: "elong_hotel",
}
2024-07-15 23:11:04 +08:00
result, err := a.api.GetExternalChannelConfig(context.Background(), req, "huidu")
2024-07-14 22:14:27 +08:00
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-08-01 23:44:11 +08:00
func (a *apiClientSuite) Test_GenerateWechtUrl() {
req := GenerateWechatUrlRequest{
//ActivityUrl: "/page/home/webview/webview?src=https%3A%2F%2Fmp.elong.com%2Ftenthousandaura%2F%3Factivitycode%3D5fd89a11-7b58-4f5c-8dc9-c360936d4207%26of%3D99810010",
ActivityUrl: "/page/home/webview/webview?src=https%3A%2F%2Fmp.elong.com%2Ftenthousandaura%2F%3Factivitycode%3D73086812-aaae-48ba-b14a-f087a6b61a92%26isSocket%3DHotelActivityId_9043%26of%3D5027785&isRefresh=refresh&isSocket=HotelActivityId_9043",
2024-07-15 23:11:04 +08:00
Uid: "11111111111111111",
}
2024-08-01 23:44:11 +08:00
result, err := a.api.GenerateWechatUrl(context.Background(), req)
2024-07-15 23:11:04 +08:00
if !a.NoError(err) {
a.T().Errorf("========[Test_GenerateUrl] response error:%s", err)
return
}
a.T().Logf("=====[Test_GenerateUrl] result: %s", string(result))
}
2024-08-01 23:44:11 +08:00
func (a *apiClientSuite) Test_GenerateH5Url() {
req := GenerateH5UrlRequest{
ActivityUrl: "https://cms.zhongdiantui.com/#/pages/toMiniProgram/toMiniProgram?type=2sfee",
2024-08-01 23:44:11 +08:00
LinkCode: "ffaefe3r3434334trq34",
ActId: "100006",
}
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", string(result))
}
2024-07-14 22:14:27 +08:00
func (a *apiClientSuite) Test_QueryOrderList() {
req := QueryOrderListRequest{
Trackid: "",
BeginDate: "2024-07-01 00:00:00",
EndDate: "2024-07-01 23:59:59",
Update: 1,
PageIndex: 0,
PageSize: 1,
}
result, err := a.api.QueryOrderList(context.Background(), req, "huidu")
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))
}