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

Method TestInvokeLargeErr

test/invoke_test.go:53–78  ·  view source on GitHub ↗

TestInvokeLargeErr verifies an invocation of ClientConn.Invoke() where the server returns a really large error message.

(t *testing.T)

Source from the content-addressed store, hash-verified

51// TestInvokeLargeErr verifies an invocation of ClientConn.Invoke() where the
52// server returns a really large error message.
53func (s) TestInvokeLargeErr(t *testing.T) {
54 largeErrorStr := strings.Repeat("A", 1024*1024)
55 ss := &stubserver.StubServer{
56 EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) {
57 return &testpb.Empty{}, status.Error(codes.Internal, largeErrorStr)
58 },
59 }
60 if err := ss.Start(nil); err != nil {
61 t.Fatalf("Failed to start stub server: %v", err)
62 }
63 defer ss.Stop()
64
65 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
66 defer cancel()
67 err := ss.CC.Invoke(ctx, "/grpc.testing.TestService/EmptyCall", &testpb.Empty{}, &testpb.Empty{})
68 if err == nil {
69 t.Fatal("grpc.Invoke(\"/grpc.testing.TestService/EmptyCall\") succeeded when expected to fail")
70 }
71 st, ok := status.FromError(err)
72 if !ok {
73 t.Fatal("grpc.Invoke(\"/grpc.testing.TestService/EmptyCall\") received non-status error")
74 }
75 if status.Code(err) != codes.Internal || st.Message() != largeErrorStr {
76 t.Fatalf("grpc.Invoke(\"/grpc.testing.TestService/EmptyCall\") failed with error: %v, want an error of code %d and desc size %d", err, codes.Internal, len(largeErrorStr))
77 }
78}
79
80// TestInvokeErrorSpecialChars tests an invocation of ClientConn.Invoke() and
81// verifies that error messages don't get mangled.

Callers

nothing calls this directly

Calls 9

StartMethod · 0.95
StopMethod · 0.95
ErrorFunction · 0.92
FromErrorFunction · 0.92
CodeFunction · 0.92
MessageMethod · 0.80
FatalfMethod · 0.65
InvokeMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected