createTestInvoker is the main test setup function. It returns an Invoker using the provided mockServer, as well as a shutdown function. The Invoker does not need to be closed directly, that will be handled by the shutdown function.
(t *testing.T, server *mockServer)
| 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. |
| 59 | func createTestInvoker(t *testing.T, server *mockServer) (Invoker, func(), error) { |
| 60 | listener, err := net.Listen("tcp", "127.0.0.1:16634") |
| 61 | if err != nil { |
| 62 | return nil, nil, fmt.Errorf("failed to listen: %w", err) |
| 63 | } |
| 64 | |
| 65 | ctx, cancel := context.WithCancel(context.Background()) |
| 66 | ch := make(chan error) |
| 67 | go func() { ch <- runTestGrpcServer(ctx, listener, server) }() |
| 68 | |
| 69 | close := func() { |
| 70 | cancel() |
| 71 | <-ch |
| 72 | listener.Close() |
| 73 | } |
| 74 | |
| 75 | // Create a new invoker with a mock port forwarder |
| 76 | invoker, err := CreateInvoker(context.Background(), rpctest.PortForwarder{}) |
| 77 | if err != nil { |
| 78 | close() |
| 79 | return nil, nil, fmt.Errorf("error connecting to internal server: %w", err) |
| 80 | } |
| 81 | |
| 82 | return invoker, func() { |
| 83 | invoker.Close() |
| 84 | close() |
| 85 | }, nil |
| 86 | } |
| 87 | |
| 88 | // Test that the RPC invoker notifies the codespace of client activity on connection |
| 89 | func verifyNotifyCodespaceOfClientActivity(t *testing.T, server *mockServer) { |
no test coverage detected