test query notify
This commit is contained in:
parent
0e1b13b26e
commit
3adab98e89
|
@ -15,14 +15,16 @@ var notifyUrl = "http://test.openapi.1688sup.cn"
|
|||
|
||||
var zltx = &ZltxService{}
|
||||
|
||||
func TestOrder(t *testing.T) {
|
||||
request := &proto.OrderRequest{
|
||||
Config: &proto.Config{
|
||||
var config = &proto.Config{
|
||||
AppId: appId,
|
||||
AppKey: appKey,
|
||||
BaseUri: baseUri,
|
||||
NotifyUrl: notifyUrl,
|
||||
},
|
||||
}
|
||||
|
||||
func TestOrder(t *testing.T) {
|
||||
request := &proto.OrderRequest{
|
||||
Config: config,
|
||||
Order: &proto.OrderRequest_Order{
|
||||
OrderNo: "test_zltx_4",
|
||||
Account: "18666666666",
|
||||
|
@ -43,3 +45,40 @@ func TestOrder(t *testing.T) {
|
|||
assert.Equal(t, int(proto.Status_ING), int(got.Result.Status))
|
||||
})
|
||||
}
|
||||
|
||||
func TestQuery(t *testing.T) {
|
||||
request := &proto.QueryRequest{
|
||||
Config: config,
|
||||
Order: &proto.QueryRequest_Order{
|
||||
OrderNo: "test_zltx_4",
|
||||
TradeNo: "",
|
||||
Account: "",
|
||||
Extra: nil,
|
||||
},
|
||||
}
|
||||
t.Run("TestQuery", func(t *testing.T) {
|
||||
got, err := zltx.Query(context.Background(), request)
|
||||
if err != nil {
|
||||
t.Errorf("Query() error = %v", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("%+v \n", got)
|
||||
assert.Equal(t, int(proto.Status_SUCCESS), int(got.Result.Status))
|
||||
})
|
||||
}
|
||||
|
||||
func TestNotify(t *testing.T) {
|
||||
in := &proto.NotifyRequest{
|
||||
Queries: nil,
|
||||
Headers: nil,
|
||||
Body: []byte(`{"merchantId":10, "outTradeNo":"123", "rechargeAccount":"1866666666", "status":"01", "sign":"sign"}`),
|
||||
}
|
||||
t.Run("TestNotify", func(t *testing.T) {
|
||||
got, err := zltx.Notify(context.Background(), in)
|
||||
if assert.Nil(t, err) {
|
||||
assert.Equal(t, true, got.Result)
|
||||
}
|
||||
fmt.Printf("%+v \n", got)
|
||||
assert.Equal(t, int(proto.Status_SUCCESS), int(got.Result.Status))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue