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

Method TestUnaryServerInterceptorGetsConnection

test/end2end_test.go:6655–6668  ·  view source on GitHub ↗

TestUnaryServerInterceptorGetsConnection tests whether the accepted conn on the server gets to any unary interceptors on the server side.

(t *testing.T)

Source from the content-addressed store, hash-verified

6653// TestUnaryServerInterceptorGetsConnection tests whether the accepted conn on
6654// the server gets to any unary interceptors on the server side.
6655func (s) TestUnaryServerInterceptorGetsConnection(t *testing.T) {
6656 ss := &stubserver.StubServer{}
6657 if err := ss.Start([]grpc.ServerOption{grpc.UnaryInterceptor(unaryInterceptorVerifyConn)}); err != nil {
6658 t.Fatalf("Error starting endpoint server: %v", err)
6659 }
6660 defer ss.Stop()
6661
6662 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
6663 defer cancel()
6664
6665 if _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{}); status.Code(err) != codes.OK {
6666 t.Fatalf("ss.Client.EmptyCall(_, _) = _, %v, want _, error code %s", err, codes.OK)
6667 }
6668}
6669
6670func streamingInterceptorVerifyConn(_ any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error {
6671 conn := transport.GetConnection(ss.Context())

Callers

nothing calls this directly

Calls 6

StartMethod · 0.95
StopMethod · 0.95
UnaryInterceptorFunction · 0.92
CodeMethod · 0.80
FatalfMethod · 0.65
EmptyCallMethod · 0.65

Tested by

no test coverage detected