Skip to content

Commit

Permalink
fix: adjust SkipDecoder tests (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
DMwangnima authored Jun 7, 2024
1 parent 64a6da0 commit 593fa06
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions thriftrpc/normalcall/normalcall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,34 +437,67 @@ func TestNoDefaultSerdes(t *testing.T) {
desc string
hostPorts []string
opts []client.Option
expectErr bool
}{
{
desc: "use FastCodec and SkipDecoder, connect to Frugal and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFrugalAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead | thrift.EnableSkipDecoder)),
},
},
{
desc: "use Frugal and SkipDecoder, connect to Frugal and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFrugalAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead | thrift.EnableSkipDecoder)),
},
},
{
desc: "use FastCodec and SkipDecoder, connect to FastCodec and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFastCodecAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead | thrift.EnableSkipDecoder)),
},
},
{
desc: "use Frugal and SkipDecoder, connect to FastCodec and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFastCodecAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead | thrift.EnableSkipDecoder)),
},
},
{
desc: "use FastCodec, connect to Frugal and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFrugalAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead)),
},
expectErr: true,
},
{
desc: "use Frugal, connect to Frugal and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFrugalAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead)),
},
expectErr: true,
},
{
desc: "use FastCodec, connect to FastCodec and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFastCodecAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead)),
},
expectErr: true,
},
{
desc: "use Frugal, connect to Frugal and SkipDecoder enabled server",
desc: "use Frugal, connect to FastCodec and SkipDecoder enabled server",
hostPorts: []string{noDefSerdesFastCodecAddr},
opts: []client.Option{
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead)),
},
expectErr: true,
},
}
for _, tc := range testCases {
Expand All @@ -473,8 +506,12 @@ func TestNoDefaultSerdes(t *testing.T) {
ctx, stReq := thriftrpc.CreateNoDefSerdesSTRequest(context.Background())
for i := 0; i < 3; i++ {
stResp, err := cliNoDefSerdes.TestSTReq(ctx, stReq)
test.Assert(t, err == nil, err)
test.Assert(t, stReq.Str == stResp.Str)
if !tc.expectErr {
test.Assert(t, err == nil, err)
test.Assert(t, stReq.Str == stResp.Str)
} else {
test.Assert(t, err != nil)
}
}
})
}
Expand Down

0 comments on commit 593fa06

Please sign in to comment.