github.com/artisanhe/tools@v1.0.1-0.20210607022958-19a8fef2eb04/courier/transport_grpc/encode_decode_test.go (about) 1 package transport_grpc 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/artisanhe/tools/courier" 9 "github.com/artisanhe/tools/courier/transport_grpc/testify" 10 ) 11 12 type Op struct { 13 ID string `json:"id" in:"path"` 14 Ping string `json:"ping" in:"query"` 15 courier.EmptyOperator 16 } 17 18 func TestCreateStreamHandler(t *testing.T) { 19 tt := assert.New(t) 20 21 stream := testify.NewStreamMock(&MsgPackCodec{}) 22 23 stream.SendMsg(Op{ 24 ID: "id", 25 Ping: "ping", 26 }) 27 28 op := Op{} 29 30 err := MarshalOperator(stream, &op) 31 tt.Nil(err) 32 tt.Equal(op.Ping, "ping") 33 tt.Equal(op.ID, "id") 34 }