service/library/payclients/wxpaycli/client_test.go

43 lines
813 B
Go
Raw Normal View History

2024-02-05 01:15:29 +08:00
package wxpaycli
import (
"context"
"fmt"
"os"
2024-02-05 21:55:44 +08:00
"service/app/mix/conf"
2024-02-05 01:15:29 +08:00
"service/library/configcenter"
"service/library/idgenerator"
"testing"
)
func TestMain(m *testing.M) {
2024-02-05 21:55:44 +08:00
cfg := new(conf.ConfigSt)
err := configcenter.LoadConfig("/Users/erwin/wishpalv2/service/etc/mix/mix-test.yaml", cfg)
if err != nil {
fmt.Printf("%v\n", err)
2024-02-05 01:15:29 +08:00
}
2024-02-05 21:55:44 +08:00
err = Init(cfg.Wxpay)
2024-02-05 01:15:29 +08:00
if err != nil {
fmt.Println(err)
os.Exit(1)
}
m.Run()
}
func TestWxpayClient_NativePay(t *testing.T) {
cli := GetDefaultWxpayClient()
resp, err := cli.NativePay(context.Background(), &NativePayParam{
Description: "测试哈哈",
OutTradeNo: idgenerator.GenOrderId(),
TotalAmount: 1,
TimeOutSeconds: 3600 * 24,
})
if err != nil {
fmt.Println(err.Error())
return
}
2024-02-05 21:16:49 +08:00
t.Log(fmt.Sprintf("%#v", resp))
2024-02-05 01:15:29 +08:00
return
}