587 lines
13 KiB
Go
587 lines
13 KiB
Go
package weipinshang_api
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
)
|
|
|
|
func TestWeiPinShangClient_GetManyPostage(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
//type args struct {
|
|
// ip string
|
|
//}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args GetManyPostageReq
|
|
wantRes *GetManyPostageRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: GetManyPostageReq{
|
|
GoodsInfo: "[{\"goodsId\":\"WPS592_00019\",\"goodSpecId\":\"WPS592_1105165115160944\",\"num\":1},{\"goodsId\":\"WPS505_00007\",\"goodSpecId\":\"WPS505_1007111249857536\",\"num\":1}]",
|
|
Province: "广东省",
|
|
Address: "奥园",
|
|
City: "广州市",
|
|
County: "番禺区",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.GetManyPostage(&test.args)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_PreOrder(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
//type args struct {
|
|
// ip string
|
|
//}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args PreOrderReq
|
|
wantRes *PreOrderRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: PreOrderReq{
|
|
GoodsInfo: "[{\"goodsId\":\"WPS2_1231155626421463\",\"goodSpecId\":\"WPS2_12311556265677476\",\"num\":1}]",
|
|
Province: "广东省",
|
|
Address: "奥园",
|
|
City: "广州市",
|
|
Area: "番禺区",
|
|
ConsigneePhone: "15375390426",
|
|
ConsigneeContacts: "张三",
|
|
LockCode: "L100000002",
|
|
Source: "AILEHUI",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.PreOrder(&test.args)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_CreateOrder(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
//type args struct {
|
|
// ip string
|
|
//}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args CreateOrderReq
|
|
wantRes *CreateOrderRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: CreateOrderReq{
|
|
LockCode: "L100000002",
|
|
OrderNo: "2000000001",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.CreateOrder(&test.args)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_GetOrderInfo(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
type args struct {
|
|
orderNo string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantRes *GetOrderInfoRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: args{
|
|
//orderNo: "20250527172503439229",
|
|
//orderNo: "10000000000",
|
|
orderNo: "20000000000",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.GetOrderInfo(test.args.orderNo)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_GetOrderInfoByItemNO(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
type args struct {
|
|
mcOrderNo string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantRes *GetOrderInfoByItemNORes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: args{
|
|
//mcOrderNo: "mc20250527174640537475",
|
|
mcOrderNo: "mc20250616115732440085",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.GetOrderInfoByItemNO(test.args.mcOrderNo)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_GetOrderInfoByThirdNO(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
type args struct {
|
|
orderNo string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantRes *GetOrderInfoByThirdNORes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: args{
|
|
//orderNo: "10000000000",
|
|
orderNo: "20000000000",
|
|
},
|
|
},
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: args{
|
|
orderNo: "570853643339733632",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.GetOrderInfoByThirdNO(test.args.orderNo)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_IsRefund(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
type args struct {
|
|
mcOrderNo string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantRes *IsRefundRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: args{
|
|
mcOrderNo: "mc20250613182629112823",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.IsRefund(test.args.mcOrderNo)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_OrderCancel(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
type args struct {
|
|
mcOrderNo string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
wantRes *IsRefundRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: args{
|
|
mcOrderNo: "mc20250529102347485667",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.OrderCancel(test.args.mcOrderNo)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWeiPinShangClient_CreateAfsApply(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args CreateAfsApplyReq
|
|
wantRes *IsRefundRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: CreateAfsApplyReq{
|
|
CustomerContactName: "钟",
|
|
CustomerExpect: 10,
|
|
CustomerMobilePhone: "15375399426",
|
|
CustomerTel: "15375399426",
|
|
McOrderNo: "mc20250613182629112823",
|
|
PickwareAddress: "奥园",
|
|
PickwareCity: "广州",
|
|
PickwareCounty: "番禺",
|
|
PickwareProvince: "广东",
|
|
QuestionDesc: "商品问题",
|
|
QuestionPic: "11",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.CreateAfsApply(&test.args)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// test ---------------------------------------------------
|
|
|
|
func TestWeiPinShangClient_DeliverGoods(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args DeliverGoodsReq
|
|
wantRes *TestRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: DeliverGoodsReq{
|
|
COrderItemNo: "mc20250613182629112823",
|
|
CDeliveryName: "顺丰",
|
|
CDeliveryNo: "1234567890",
|
|
},
|
|
},
|
|
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: DeliverGoodsReq{
|
|
COrderItemNo: "mc20250616113428587322",
|
|
CDeliveryName: "顺丰0",
|
|
CDeliveryNo: "SF9900000099",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.DeliverGoods(&test.args)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
func TestWeiPinShangClient_UpdateService(t *testing.T) {
|
|
type fields struct {
|
|
Host string
|
|
ChannelType string
|
|
Key string
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args UpdateServiceReq
|
|
wantRes *TestRes
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: UpdateServiceReq{
|
|
COrderItemNo: "mc20250612153935670660",
|
|
CType: "1",
|
|
},
|
|
},
|
|
|
|
{
|
|
name: "test1",
|
|
fields: fields{
|
|
Host: "https://uat.api.weipinshang.net/",
|
|
ChannelType: "AILEHUI",
|
|
Key: "f654ea5bde7635c3f46191191e5c4c8e",
|
|
},
|
|
args: UpdateServiceReq{
|
|
COrderItemNo: "mc20250609180246814560",
|
|
CType: "3",
|
|
},
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
h := &WeiPinShangClient{
|
|
Host: test.fields.Host,
|
|
ChannelType: test.fields.ChannelType,
|
|
Key: test.fields.Key,
|
|
}
|
|
|
|
gotRes, err := h.UpdateService(&test.args)
|
|
|
|
log.Println(gotRes, err)
|
|
|
|
if (err != nil) != test.wantErr {
|
|
t.Errorf("GetManyPostage() error = %v, wantErr %v", err, test.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|