StubServer is a server that is easy to customize within individual test cases.
| 52 | // StubServer is a server that is easy to customize within individual test |
| 53 | // cases. |
| 54 | type StubServer struct { |
| 55 | // Guarantees we satisfy this interface; panics if unimplemented methods are called. |
| 56 | testgrpc.TestServiceServer |
| 57 | |
| 58 | // Customizable implementations of server handlers. |
| 59 | EmptyCallF func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) |
| 60 | UnaryCallF func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) |
| 61 | FullDuplexCallF func(stream testgrpc.TestService_FullDuplexCallServer) error |
| 62 | StreamingInputCallF func(stream testgrpc.TestService_StreamingInputCallServer) error |
| 63 | StreamingOutputCallF func(req *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error |
| 64 | |
| 65 | // A client connected to this service the test may use. Created in Start(). |
| 66 | Client testgrpc.TestServiceClient |
| 67 | CC *grpc.ClientConn |
| 68 | |
| 69 | // Server to serve this service from. |
| 70 | // |
| 71 | // If nil, a new grpc.Server is created, listening on the provided Network |
| 72 | // and Address fields, or listening using the provided Listener. |
| 73 | S GRPCServer |
| 74 | |
| 75 | // Parameters for Listen and Dial. Defaults will be used if these are empty |
| 76 | // before Start. |
| 77 | Network string |
| 78 | Address string |
| 79 | Target string |
| 80 | |
| 81 | // Custom listener to use for serving. If unspecified, a new listener is |
| 82 | // created on a local port. |
| 83 | Listener net.Listener |
| 84 | |
| 85 | cleanups []func() // Lambdas executed in Stop(); populated by Start(). |
| 86 | |
| 87 | // Set automatically if Target == "" |
| 88 | R *manual.Resolver |
| 89 | } |
| 90 | |
| 91 | // EmptyCall is the handler for testpb.EmptyCall |
| 92 | func (ss *StubServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected