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

Function runTestGrpcServer

internal/codespaces/rpc/invoker_test.go:38–55  ·  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

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