Skip to content

Commit 593fa06

Browse files
authored
fix: adjust SkipDecoder tests (#77)
1 parent 64a6da0 commit 593fa06

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

thriftrpc/normalcall/normalcall_test.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,34 +437,67 @@ func TestNoDefaultSerdes(t *testing.T) {
437437
desc string
438438
hostPorts []string
439439
opts []client.Option
440+
expectErr bool
440441
}{
442+
{
443+
desc: "use FastCodec and SkipDecoder, connect to Frugal and SkipDecoder enabled server",
444+
hostPorts: []string{noDefSerdesFrugalAddr},
445+
opts: []client.Option{
446+
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead | thrift.EnableSkipDecoder)),
447+
},
448+
},
449+
{
450+
desc: "use Frugal and SkipDecoder, connect to Frugal and SkipDecoder enabled server",
451+
hostPorts: []string{noDefSerdesFrugalAddr},
452+
opts: []client.Option{
453+
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead | thrift.EnableSkipDecoder)),
454+
},
455+
},
456+
{
457+
desc: "use FastCodec and SkipDecoder, connect to FastCodec and SkipDecoder enabled server",
458+
hostPorts: []string{noDefSerdesFastCodecAddr},
459+
opts: []client.Option{
460+
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead | thrift.EnableSkipDecoder)),
461+
},
462+
},
463+
{
464+
desc: "use Frugal and SkipDecoder, connect to FastCodec and SkipDecoder enabled server",
465+
hostPorts: []string{noDefSerdesFastCodecAddr},
466+
opts: []client.Option{
467+
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead | thrift.EnableSkipDecoder)),
468+
},
469+
},
441470
{
442471
desc: "use FastCodec, connect to Frugal and SkipDecoder enabled server",
443472
hostPorts: []string{noDefSerdesFrugalAddr},
444473
opts: []client.Option{
445474
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead)),
446475
},
476+
expectErr: true,
447477
},
448478
{
449479
desc: "use Frugal, connect to Frugal and SkipDecoder enabled server",
450480
hostPorts: []string{noDefSerdesFrugalAddr},
451481
opts: []client.Option{
452482
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead)),
453483
},
484+
expectErr: true,
454485
},
455486
{
456487
desc: "use FastCodec, connect to FastCodec and SkipDecoder enabled server",
457488
hostPorts: []string{noDefSerdesFastCodecAddr},
458489
opts: []client.Option{
459490
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead)),
460491
},
492+
expectErr: true,
461493
},
462494
{
463-
desc: "use Frugal, connect to Frugal and SkipDecoder enabled server",
495+
desc: "use Frugal, connect to FastCodec and SkipDecoder enabled server",
464496
hostPorts: []string{noDefSerdesFastCodecAddr},
465497
opts: []client.Option{
466498
client.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FrugalWrite | thrift.FrugalRead)),
467499
},
500+
expectErr: true,
468501
},
469502
}
470503
for _, tc := range testCases {
@@ -473,8 +506,12 @@ func TestNoDefaultSerdes(t *testing.T) {
473506
ctx, stReq := thriftrpc.CreateNoDefSerdesSTRequest(context.Background())
474507
for i := 0; i < 3; i++ {
475508
stResp, err := cliNoDefSerdes.TestSTReq(ctx, stReq)
476-
test.Assert(t, err == nil, err)
477-
test.Assert(t, stReq.Str == stResp.Str)
509+
if !tc.expectErr {
510+
test.Assert(t, err == nil, err)
511+
test.Assert(t, stReq.Str == stResp.Str)
512+
} else {
513+
test.Assert(t, err != nil)
514+
}
478515
}
479516
})
480517
}

0 commit comments

Comments
 (0)