115 lines
2.1 KiB
Go
115 lines
2.1 KiB
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
"voucher/internal/biz/businesserr"
|
|
)
|
|
|
|
func Test_SendCoupon(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
}{
|
|
{
|
|
name: "发券",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if err := SendCoupon(); err != nil {
|
|
if ee, ok := err.(*businesserr.BusinessErr); ok {
|
|
t.Errorf("errorcode:%s,errmsg:%s", ee.Code, ee.Message)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_QueryCoupon(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
appId string
|
|
openId string
|
|
couponId string
|
|
}{
|
|
{
|
|
name: "查询券订单信息",
|
|
appId: "wx619991cc795028f5",
|
|
openId: "oSNb4fnRWr7HdgbDOO8TD66LXofE",
|
|
couponId: "147089832782",
|
|
},
|
|
{
|
|
name: "查询券订单信息",
|
|
appId: "wx619991cc795028f5",
|
|
openId: "oSNb4foo87dBNx1D9KTH-bB-G6YA",
|
|
couponId: "147094824239",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
QueryCoupon(tt.appId, tt.openId, tt.couponId)
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_QueryProduct(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
}{
|
|
{
|
|
name: "查询券商品信息",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
QueryProduct()
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_QueryCallback(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
}{
|
|
{
|
|
name: "查询券核销通知地址",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
QueryCallback()
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestGetErrorByDescription(t *testing.T) {
|
|
//e := &businesserr.ErrBody{
|
|
// Code: "INVALID_REQUEST",
|
|
// Message: "活动已结束或未激活",
|
|
//}
|
|
//t.Log(e.GetWechatError())
|
|
//
|
|
//err := gorm.ErrRecordNotFound
|
|
//
|
|
//t.Log(errors.Is(err, gorm.ErrRecordNotFound))
|
|
}
|
|
|
|
func TestErr(t *testing.T) {
|
|
//e := &businesserr.ErrBody{
|
|
// Code: "INVALID_REQUEST",
|
|
// Message: "活动已结束或未激活",
|
|
//}
|
|
//
|
|
//se := errors2.FromError(e.GetWechatError())
|
|
//
|
|
//t.Log(se.Reason)
|
|
//t.Log(se.Message)
|
|
//
|
|
//e2 := errors.New("活动已结束或未激活")
|
|
//se2 := errors2.FromError(e2)
|
|
//
|
|
//t.Log(se2.Reason)
|
|
//t.Log(len(se2.Reason))
|
|
//t.Log(se2.Message)
|
|
}
|