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

Function TestNodeUpdater_setAddresses_same

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

Source from the content-addressed store, hash-verified

400}
401
402func TestNodeUpdater_setAddresses_same(t *testing.T) {
403 t.Parallel()
404 ctx := testutil.Context(t, testutil.WaitShort)
405 logger := testutil.Logger(t)
406 id := tailcfg.NodeID(1)
407 nodeKey := key.NewNode().Public()
408 discoKey := key.NewDisco().Public()
409 nodeCh := make(chan *Node)
410 uut := newNodeUpdater(
411 logger,
412 func(n *Node) {
413 nodeCh <- n
414 },
415 id, nodeKey, discoKey,
416 )
417 defer uut.close()
418
419 // Then: we don't configure
420 requireNeverConfigures(ctx, t, &uut.phased)
421
422 // Given: preferred DERP is 1, so we would send an update on change &&
423 // addrs already set
424 addrs := []netip.Prefix{netip.MustParsePrefix("192.168.0.200/32")}
425 uut.L.Lock()
426 uut.preferredDERP = 1
427 uut.addresses = slices.Clone(addrs)
428 uut.L.Unlock()
429
430 // When: we set addrs
431 uut.setAddresses(addrs)
432
433 done := make(chan struct{})
434 go func() {
435 defer close(done)
436 uut.close()
437 }()
438 _ = testutil.TryReceive(ctx, t, done)
439}
440
441func TestNodeUpdater_setCallback(t *testing.T) {
442 t.Parallel()

Callers

nothing calls this directly

Calls 10

ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
newNodeUpdaterFunction · 0.85
requireNeverConfiguresFunction · 0.85
closeMethod · 0.65
LockMethod · 0.45
CloneMethod · 0.45
UnlockMethod · 0.45
setAddressesMethod · 0.45

Tested by

no test coverage detected