From bc39e465ca8e31a595365d85a5a715c7a26184d5 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 16 Apr 2024 15:02:54 +0800 Subject: [PATCH] protojson --- pkg/common/cmd/msg_gateway_test.go | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkg/common/cmd/msg_gateway_test.go b/pkg/common/cmd/msg_gateway_test.go index 5908877ed..d820627b5 100644 --- a/pkg/common/cmd/msg_gateway_test.go +++ b/pkg/common/cmd/msg_gateway_test.go @@ -15,7 +15,12 @@ package cmd import ( + "github.com/openimsdk/protocol/auth" + "github.com/openimsdk/tools/apiresp" + "github.com/openimsdk/tools/utils/jsonutil" "github.com/stretchr/testify/mock" + "math" + "testing" ) // MockRootCmd is a mock type for the RootCmd type @@ -27,3 +32,30 @@ func (m *MockRootCmd) Execute() error { args := m.Called() return args.Error(0) } + +func TestName(t *testing.T) { + resp := &apiresp.ApiResponse{ + ErrCode: 1234, + ErrMsg: "test", + ErrDlt: "4567", + Data: &auth.UserTokenResp{ + Token: "1234567", + ExpireTimeSeconds: math.MaxInt64, + }, + } + data, err := resp.MarshalJSON() + if err != nil { + panic(err) + } + t.Log(string(data)) + + var rReso apiresp.ApiResponse + rReso.Data = &auth.UserTokenResp{} + + if err := jsonutil.JsonUnmarshal(data, &rReso); err != nil { + panic(err) + } + + t.Logf("%+v\n", rReso) + +}