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

Function DoStatusCodeAndMessage

interop/test_utils.go:578–610  ·  view source on GitHub ↗

DoStatusCodeAndMessage checks that the status code is propagated back to the client.

(ctx context.Context, tc testgrpc.TestServiceClient, args ...grpc.CallOption)

Source from the content-addressed store, hash-verified

576
577// DoStatusCodeAndMessage checks that the status code is propagated back to the client.
578func DoStatusCodeAndMessage(ctx context.Context, tc testgrpc.TestServiceClient, args ...grpc.CallOption) {
579 var code int32 = 2
580 msg := "test status message"
581 expectedErr := status.Error(codes.Code(code), msg)
582 respStatus := &testpb.EchoStatus{
583 Code: code,
584 Message: msg,
585 }
586 // Test UnaryCall.
587 req := &testpb.SimpleRequest{
588 ResponseStatus: respStatus,
589 }
590 if _, err := tc.UnaryCall(ctx, req, args...); err == nil || err.Error() != expectedErr.Error() {
591 logger.Fatalf("%v.UnaryCall(_, %v) = _, %v, want _, %v", tc, req, err, expectedErr)
592 }
593 // Test FullDuplexCall.
594 stream, err := tc.FullDuplexCall(ctx, args...)
595 if err != nil {
596 logger.Fatalf("%v.FullDuplexCall(_) = _, %v, want <nil>", tc, err)
597 }
598 streamReq := &testpb.StreamingOutputCallRequest{
599 ResponseStatus: respStatus,
600 }
601 if err := stream.Send(streamReq); err != nil {
602 logger.Fatalf("%v has error %v while sending %v, want <nil>", stream, err, streamReq)
603 }
604 if err := stream.CloseSend(); err != nil {
605 logger.Fatalf("%v.CloseSend() = %v, want <nil>", stream, err)
606 }
607 if _, err = stream.Recv(); err.Error() != expectedErr.Error() {
608 logger.Fatalf("%v.Recv() returned error %v, want %v", stream, err, expectedErr)
609 }
610}
611
612// DoSpecialStatusMessage verifies Unicode and whitespace is correctly processed
613// in status message.

Callers 2

mainFunction · 0.92
performRPCsFunction · 0.92

Calls 9

ErrorFunction · 0.92
CodeTypeAlias · 0.92
UnaryCallMethod · 0.65
ErrorMethod · 0.65
FatalfMethod · 0.65
FullDuplexCallMethod · 0.65
SendMethod · 0.65
CloseSendMethod · 0.65
RecvMethod · 0.65

Tested by

no test coverage detected