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

Function TestNodeUpdater_setStatus_outdated

tailnet/node_internal_test.go:319–359  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

317}
318
319func TestNodeUpdater_setStatus_outdated(t *testing.T) {
320 t.Parallel()
321 ctx := testutil.Context(t, testutil.WaitShort)
322 logger := testutil.Logger(t)
323 id := tailcfg.NodeID(1)
324 nodeKey := key.NewNode().Public()
325 discoKey := key.NewDisco().Public()
326 nodeCh := make(chan *Node)
327 uut := newNodeUpdater(
328 logger,
329 func(n *Node) {
330 nodeCh <- n
331 },
332 id, nodeKey, discoKey,
333 )
334 defer uut.close()
335
336 // Then: we don't configure
337 requireNeverConfigures(ctx, t, &uut.phased)
338
339 // Given: preferred DERP is 1, so we would send an update on change && lastStatus set ahead
340 ahead := time.Date(2024, 1, 10, 8, 0o0, 1, 0, time.UTC)
341 behind := time.Date(2024, 1, 10, 8, 0o0, 0, 0, time.UTC)
342 uut.L.Lock()
343 uut.preferredDERP = 1
344 uut.lastStatus = ahead
345 uut.L.Unlock()
346
347 // When: we set a status with endpoints {[fe80::1]:5678}, with AsOf set behind
348 uut.setStatus(&wgengine.Status{
349 LocalAddrs: []tailcfg.Endpoint{{Addr: netip.MustParseAddrPort("[fe80::1]:5678")}},
350 AsOf: behind,
351 }, xerrors.New("test"))
352
353 done := make(chan struct{})
354 go func() {
355 defer close(done)
356 uut.close()
357 }()
358 _ = testutil.TryReceive(ctx, t, done)
359}
360
361func TestNodeUpdater_setAddresses_different(t *testing.T) {
362 t.Parallel()

Callers

nothing calls this directly

Calls 10

ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
newNodeUpdaterFunction · 0.85
requireNeverConfiguresFunction · 0.85
setStatusMethod · 0.80
closeMethod · 0.65
NewMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected