MCPcopy Index your code
hub / github.com/cli/cli / runTestGrpcServer

Function runTestGrpcServer

internal/codespaces/rpc/invoker_test.go:39–56  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
39func 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.

Callers 1

createTestInvokerFunction · 0.85

Calls 4

DoneMethod · 0.65

Tested by

no test coverage detected