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

Method TestNilStatsHandler

test/end2end_test.go:6993–7010  ·  view source on GitHub ↗

TestNilStatsHandler ensures we do not panic as a result of a nil stats handler.

(t *testing.T)

Source from the content-addressed store, hash-verified

6991// TestNilStatsHandler ensures we do not panic as a result of a nil stats
6992// handler.
6993func (s) TestNilStatsHandler(t *testing.T) {
6994 grpctest.ExpectErrorN("ignoring nil parameter", 2)
6995 ss := &stubserver.StubServer{
6996 UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
6997 return &testpb.SimpleResponse{}, nil
6998 },
6999 }
7000 if err := ss.Start([]grpc.ServerOption{grpc.StatsHandler(nil)}, grpc.WithStatsHandler(nil)); err != nil {
7001 t.Fatalf("Error starting endpoint server: %v", err)
7002 }
7003 defer ss.Stop()
7004
7005 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
7006 defer cancel()
7007 if _, err := ss.Client.UnaryCall(ctx, &testpb.SimpleRequest{}); err != nil {
7008 t.Fatalf("Unexpected error from UnaryCall: %v", err)
7009 }
7010}
7011
7012// TestUnexpectedEOF tests a scenario where a client invokes two unary RPC
7013// calls. The first call receives a payload which exceeds max grpc receive

Callers

nothing calls this directly

Calls 7

StartMethod · 0.95
StopMethod · 0.95
ExpectErrorNFunction · 0.92
StatsHandlerFunction · 0.92
WithStatsHandlerFunction · 0.92
FatalfMethod · 0.65
UnaryCallMethod · 0.65

Tested by

no test coverage detected