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

Function StartTestService

internal/stubserver/stubserver.go:289–302  ·  view source on GitHub ↗

StartTestService spins up a stub server exposing the TestService on a local port. If the passed in server is nil, a stub server that implements only the EmptyCall and UnaryCall RPCs is started.

(t *testing.T, server *StubServer, sopts ...grpc.ServerOption)

Source from the content-addressed store, hash-verified

287// port. If the passed in server is nil, a stub server that implements only the
288// EmptyCall and UnaryCall RPCs is started.
289func StartTestService(t *testing.T, server *StubServer, sopts ...grpc.ServerOption) *StubServer {
290 if server == nil {
291 server = &StubServer{
292 EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) { return &testpb.Empty{}, nil },
293 UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
294 return &testpb.SimpleResponse{}, nil
295 },
296 }
297 }
298 server.StartServer(sopts...)
299
300 t.Logf("Started test service backend at %q", server.Address)
301 return server
302}

Calls 2

StartServerMethod · 0.80
LogfMethod · 0.65