mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-06 13:22:11 +08:00
protojson
This commit is contained in:
parent
ef3081b4b7
commit
bc39e465ca
@ -15,7 +15,12 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/openimsdk/protocol/auth"
|
||||||
|
"github.com/openimsdk/tools/apiresp"
|
||||||
|
"github.com/openimsdk/tools/utils/jsonutil"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
|
"math"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockRootCmd is a mock type for the RootCmd type
|
// MockRootCmd is a mock type for the RootCmd type
|
||||||
@ -27,3 +32,30 @@ func (m *MockRootCmd) Execute() error {
|
|||||||
args := m.Called()
|
args := m.Called()
|
||||||
return args.Error(0)
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user