MCPcopy Index your code
hub / github.com/coder/coder / setupConnectedAllWorkspaceUpdatesController

Function setupConnectedAllWorkspaceUpdatesController

tailnet/controllers_test.go:1559–1593  ·  view source on GitHub ↗
(
	ctx context.Context, t testing.TB, logger slog.Logger, opts ...tailnet.TunnelAllOption,
)

Source from the content-addressed store, hash-verified

1557}
1558
1559func setupConnectedAllWorkspaceUpdatesController(
1560 ctx context.Context, t testing.TB, logger slog.Logger, opts ...tailnet.TunnelAllOption,
1561) (
1562 *fakeCoordinatorClient, *fakeWorkspaceUpdateClient, *tailnet.TunnelAllWorkspaceUpdatesController,
1563) {
1564 fConn := &fakeCoordinatee{}
1565 tsc := tailnet.NewTunnelSrcCoordController(logger, fConn)
1566 uut := tailnet.NewTunnelAllWorkspaceUpdatesController(logger, tsc, opts...)
1567
1568 // connect up a coordinator client, to track adding and removing tunnels
1569 coordC := newFakeCoordinatorClient(ctx, t)
1570 coordCW := tsc.New(coordC)
1571 t.Cleanup(func() {
1572 // hang up coord client
1573 coordRecv := testutil.TryReceive(ctx, t, coordC.resps)
1574 testutil.RequireSend(ctx, t, coordRecv.err, io.EOF)
1575 // sends close on client
1576 cCall := testutil.TryReceive(ctx, t, coordC.close)
1577 testutil.RequireSend(ctx, t, cCall, nil)
1578 err := testutil.TryReceive(ctx, t, coordCW.Wait())
1579 require.ErrorIs(t, err, io.EOF)
1580 })
1581
1582 // connect up the updates client
1583 updateC := newFakeWorkspaceUpdateClient(ctx, t)
1584 updateCW := uut.New(updateC)
1585 t.Cleanup(func() {
1586 // hang up WorkspaceUpdates client
1587 upRecvCall := testutil.TryReceive(ctx, t, updateC.recv)
1588 testutil.RequireSend(ctx, t, upRecvCall.err, io.EOF)
1589 err := testutil.TryReceive(ctx, t, updateCW.Wait())
1590 require.ErrorIs(t, err, io.EOF)
1591 })
1592 return coordC, updateC, uut
1593}
1594
1595func TestTunnelAllWorkspaceUpdatesController_Initial(t *testing.T) {
1596 t.Parallel()

Calls 10

NewMethod · 0.95
NewMethod · 0.95
TryReceiveFunction · 0.92
RequireSendFunction · 0.92
newFakeCoordinatorClientFunction · 0.85
CleanupMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected