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)
| 287 | // port. If the passed in server is nil, a stub server that implements only the |
| 288 | // EmptyCall and UnaryCall RPCs is started. |
| 289 | func 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 | } |