From 9131c0b7a65c8462dac46f6b1fef00ae127d934b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Mon, 28 Oct 2024 13:56:33 +0800 Subject: [PATCH] test --- plugins/zltx/internal/zltx_test.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/plugins/zltx/internal/zltx_test.go b/plugins/zltx/internal/zltx_test.go index 281bb19..99923fd 100644 --- a/plugins/zltx/internal/zltx_test.go +++ b/plugins/zltx/internal/zltx_test.go @@ -54,8 +54,7 @@ func TestOrder(t *testing.T) { Extra: []byte(`{}`), }, } - fmt.Println(request.String()) - //fmt.Println(StrIdx(request.String(), "order")) + fmt.Println(StrIdx(request.String(), "order")) //fmt.Println(StrIdx(request.String(), "product")) t.Run("TestOrder", func(t *testing.T) { @@ -64,6 +63,7 @@ func TestOrder(t *testing.T) { t.Errorf("Order() error = %v", err) return } + fmt.Println(StrIdx(got.String(), "result")) fmt.Printf("%+v", got) assert.Equal(t, int(proto.Status_ING), int(got.Result.Status)) }) @@ -79,13 +79,7 @@ func TestQuery(t *testing.T) { Extra: nil, }, } - requestString := request.String() - index := strings.Index(requestString, "order:") - if index == -1 { - fmt.Println("order: not found in the string") - return - } - fmt.Println(requestString[index+len("order:"):]) + fmt.Println(StrIdx(request.String(), "order")) t.Run("TestQuery", func(t *testing.T) { got, err := zltx.Query(context.Background(), request) @@ -93,14 +87,7 @@ func TestQuery(t *testing.T) { t.Errorf("Query() error = %v", err) return } - result := got.String() - fmt.Printf("%+v \n", got) - index = strings.Index(result, "result:") - if index == -1 { - fmt.Println("result: not found in the string") - return - } - fmt.Println(result[index+len("result:"):]) + fmt.Println(StrIdx(got.String(), "result")) assert.Equal(t, int(proto.Status_SUCCESS), int(got.Result.Status)) }) @@ -113,6 +100,7 @@ func TestNotify(t *testing.T) { Headers: nil, Body: []byte(`{"merchantId":23329,"outTradeNo":"202409111714224026320002","rechargeAccount":"18512869479","sign":"474ACB521DEE99551153B6CE108FD06D","status":"01"}`), } + fmt.Println(in.String()) t.Run("TestNotify", func(t *testing.T) { got, err := zltx.Notify(context.Background(), in) if !assert.Nil(t, err) {