MCPcopy
hub / github.com/grpc/grpc-go / TestUnsupportedCodecOnServer

Method TestUnsupportedCodecOnServer

encoding/encoding_test.go:384–402  ·  view source on GitHub ↗

Tests the case where the client uses a codec (one that uses proto encoding but uses a different content-subtype name) that the server does not support. Verifies that the server falls back to the proto codec and that the client can successfully make RPCs. TODO(https://github.com/grpc/grpc-go/issues/

(t *testing.T)

Source from the content-addressed store, hash-verified

382// variable to change the behavior on the server to reject unsupported codecs,
383// we should modify this test to verify that the RPC fails in that case.
384func (s) TestUnsupportedCodecOnServer(t *testing.T) {
385 backend := stubserver.StartTestService(t, nil)
386 defer backend.Stop()
387
388 cc, err := grpc.NewClient(backend.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
389 if err != nil {
390 t.Fatalf("Failed to dial test backend at %q: %v", backend.Address, err)
391 }
392 defer cc.Close()
393
394 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
395 defer cancel()
396
397 codec := &renameProtoCodec{CodecV2: encoding.GetCodecV2(proto.Name), name: t.Name()}
398 client := testgrpc.NewTestServiceClient(cc)
399 if _, err := client.EmptyCall(ctx, &testpb.Empty{}, grpc.ForceCodecV2(codec)); err != nil {
400 t.Fatalf("ss.Client.EmptyCall(_, _) = _, %v; want _, nil", err)
401 }
402}

Callers

nothing calls this directly

Calls 11

EmptyCallMethod · 0.95
StartTestServiceFunction · 0.92
NewClientFunction · 0.92
WithTransportCredentialsFunction · 0.92
NewCredentialsFunction · 0.92
GetCodecV2Function · 0.92
ForceCodecV2Function · 0.92
StopMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected