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