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)
| 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. |
| 384 | func (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 | } |
nothing calls this directly
no test coverage detected