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

Function TestInMemoryCoordination

tailnet/controllers_test.go:41–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39var errUnimplemented = drpcerr.WithCode(xerrors.New("Unimplemented"), drpcerr.Unimplemented)
40
41func TestInMemoryCoordination(t *testing.T) {
42 t.Parallel()
43 ctx := testutil.Context(t, testutil.WaitShort)
44 logger := testutil.Logger(t)
45 clientID := uuid.UUID{1}
46 agentID := uuid.UUID{2}
47 mCoord := tailnettest.NewMockCoordinator(gomock.NewController(t))
48 fConn := &fakeCoordinatee{}
49
50 reqs := make(chan *proto.CoordinateRequest, 100)
51 resps := make(chan *proto.CoordinateResponse, 100)
52 auth := tailnet.ClientCoordinateeAuth{AgentID: agentID}
53 mCoord.EXPECT().Coordinate(gomock.Any(), clientID, gomock.Any(), auth).
54 Times(1).Return(reqs, resps)
55
56 ctrl := tailnet.NewTunnelSrcCoordController(logger, fConn)
57 ctrl.AddDestination(agentID)
58 uut := ctrl.New(tailnet.NewInMemoryCoordinatorClient(logger, clientID, auth, mCoord))
59 defer uut.Close(ctx)
60
61 coordinationTest(ctx, t, uut, fConn, reqs, resps, agentID)
62
63 // Recv loop should be terminated by the server hanging up after Disconnect
64 err := testutil.TryReceive(ctx, t, uut.Wait())
65 require.ErrorIs(t, err, io.EOF)
66}
67
68func TestTunnelSrcCoordController_Mainline(t *testing.T) {
69 t.Parallel()

Callers

nothing calls this directly

Calls 13

EXPECTMethod · 0.95
AddDestinationMethod · 0.95
NewMethod · 0.95
ContextFunction · 0.92
LoggerFunction · 0.92
NewMockCoordinatorFunction · 0.92
TryReceiveFunction · 0.92
coordinationTestFunction · 0.85
CoordinateMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected