(t *testing.T)
| 1115 | } |
| 1116 | |
| 1117 | func TestController_DoesNotRedialAfterCancel(t *testing.T) { |
| 1118 | t.Parallel() |
| 1119 | testCtx := testutil.Context(t, testutil.WaitShort) |
| 1120 | ctx, cancel := context.WithCancel(testCtx) |
| 1121 | logger := testutil.Logger(t) |
| 1122 | |
| 1123 | fClient := newFakeWorkspaceUpdateClient(testCtx, t) |
| 1124 | dialer := &scriptedDialer{ |
| 1125 | attempts: make(chan int, 10), |
| 1126 | dialFn: func(_ context.Context, _ int) (tailnet.ControlProtocolClients, error) { |
| 1127 | return tailnet.ControlProtocolClients{ |
| 1128 | WorkspaceUpdates: fClient, |
| 1129 | Closer: fakeCloser{}, |
| 1130 | }, nil |
| 1131 | }, |
| 1132 | } |
| 1133 | fCtrl := newFakeUpdatesController(testCtx, t) |
| 1134 | |
| 1135 | uut := tailnet.NewController(logger.Named("ctrl"), dialer) |
| 1136 | uut.WorkspaceUpdatesCtrl = fCtrl |
| 1137 | uut.Run(ctx) |
| 1138 | |
| 1139 | require.Equal(t, 1, testutil.TryReceive(testCtx, t, dialer.attempts)) |
| 1140 | call := testutil.TryReceive(testCtx, t, fCtrl.calls) |
| 1141 | require.Equal(t, fClient, call.client) |
| 1142 | testutil.RequireSend[tailnet.CloserWaiter](testCtx, t, call.resp, newFakeCloserWaiter()) |
| 1143 | |
| 1144 | cancel() |
| 1145 | closeCall := testutil.TryReceive(testCtx, t, fClient.close) |
| 1146 | testutil.RequireSend(testCtx, t, closeCall, nil) |
| 1147 | _ = testutil.TryReceive(testCtx, t, uut.Closed()) |
| 1148 | |
| 1149 | select { |
| 1150 | case attempt := <-dialer.attempts: |
| 1151 | t.Fatalf("unexpected redial attempt after cancel: %d", attempt) |
| 1152 | default: |
| 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | func TestController_TelemetrySuccess(t *testing.T) { |
| 1157 | t.Parallel() |
nothing calls this directly
no test coverage detected