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

Function TestDialFailure

coderd/tailnet_test.go:370–399  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

368}
369
370func TestDialFailure(t *testing.T) {
371 t.Parallel()
372
373 // Setup.
374 ctx := testutil.Context(t, testutil.WaitShort)
375 logger := testutil.Logger(t)
376
377 // Given: a tailnet coordinator.
378 coord := tailnet.NewCoordinator(logger)
379 t.Cleanup(func() {
380 _ = coord.Close()
381 })
382 coordPtr := atomic.Pointer[tailnet.Coordinator]{}
383 coordPtr.Store(&coord)
384
385 // Given: a fake DB healthchecker which will always fail.
386 fch := &failingHealthcheck{}
387
388 // When: dialing the in-memory coordinator.
389 dialer := &coderd.InmemTailnetDialer{
390 CoordPtr: &coordPtr,
391 Logger: logger,
392 ClientID: uuid.UUID{5},
393 DatabaseHealthCheck: fch,
394 }
395 _, err := dialer.Dial(ctx, nil)
396
397 // Then: the error returned reflects the database has failed its healthcheck.
398 require.ErrorIs(t, err, codersdk.ErrDatabaseNotReachable)
399}
400
401type failingHealthcheck struct{}
402

Callers

nothing calls this directly

Calls 7

DialMethod · 0.95
ContextFunction · 0.92
LoggerFunction · 0.92
NewCoordinatorFunction · 0.92
CleanupMethod · 0.65
CloseMethod · 0.65
StoreMethod · 0.45

Tested by

no test coverage detected