diff --git a/plugins/zltx/internal/zltx_test.go b/plugins/zltx/internal/zltx_test.go index 6d9e9ed..67ea6ff 100644 --- a/plugins/zltx/internal/zltx_test.go +++ b/plugins/zltx/internal/zltx_test.go @@ -15,14 +15,16 @@ var notifyUrl = "http://test.openapi.1688sup.cn" var zltx = &ZltxService{} +var config = &proto.Config{ + AppId: appId, + AppKey: appKey, + BaseUri: baseUri, + NotifyUrl: notifyUrl, +} + func TestOrder(t *testing.T) { request := &proto.OrderRequest{ - Config: &proto.Config{ - AppId: appId, - AppKey: appKey, - BaseUri: baseUri, - NotifyUrl: notifyUrl, - }, + 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)) + }) +}