runTestGrpcServer serves grpc requests over the provided Listener using the mockServer for mocked callbacks. It does not return until the Context is cancelled and the server fully shuts down.
(ctx context.Context, listener net.Listener, server *mockServer)
| 37 | // runTestGrpcServer serves grpc requests over the provided Listener using the mockServer for mocked callbacks. |
| 38 | // It does not return until the Context is cancelled and the server fully shuts down. |
| 39 | func runTestGrpcServer(ctx context.Context, listener net.Listener, server *mockServer) error { |
| 40 | s := grpc.NewServer() |
| 41 | jupyter.RegisterJupyterServerHostServer(s, server) |
| 42 | codespace.RegisterCodespaceHostServer(s, server) |
| 43 | ssh.RegisterSshServerHostServer(s, server) |
| 44 | |
| 45 | ch := make(chan error, 1) |
| 46 | go func() { ch <- s.Serve(listener) }() |
| 47 | |
| 48 | select { |
| 49 | case <-ctx.Done(): |
| 50 | s.Stop() |
| 51 | <-ch |
| 52 | return nil |
| 53 | case err := <-ch: |
| 54 | return err |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // createTestInvoker is the main test setup function. It returns an Invoker using the provided mockServer, as well as a shutdown function. |
| 59 | // The Invoker does not need to be closed directly, that will be handled by the shutdown function. |
no test coverage detected