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

Function TestNodeUpdater_fillPeerDiagnostics_noCallback

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

Source from the content-addressed store, hash-verified

615}
616
617func TestNodeUpdater_fillPeerDiagnostics_noCallback(t *testing.T) {
618 t.Parallel()
619 ctx := testutil.Context(t, testutil.WaitShort)
620 logger := testutil.Logger(t)
621 id := tailcfg.NodeID(1)
622 nodeKey := key.NewNode().Public()
623 discoKey := key.NewDisco().Public()
624 uut := newNodeUpdater(
625 logger,
626 nil,
627 id, nodeKey, discoKey,
628 )
629 defer uut.close()
630
631 // at start of day, filling diagnostics will not have derp and sentNode is false
632 d := PeerDiagnostics{}
633 uut.fillPeerDiagnostics(&d)
634 require.Equal(t, 0, d.PreferredDERP)
635 require.False(t, d.SentNode)
636
637 dl := map[string]float64{"1": 0.025}
638 uut.setNetInfo(&tailcfg.NetInfo{
639 PreferredDERP: 1,
640 DERPLatency: dl,
641 })
642
643 // since there is no callback, SentNode should not be true, but we get
644 // the preferred DERP
645 uut.fillPeerDiagnostics(&d)
646 require.Equal(t, 1, d.PreferredDERP)
647 require.False(t, d.SentNode)
648
649 done := make(chan struct{})
650 go func() {
651 defer close(done)
652 uut.close()
653 }()
654 _ = testutil.TryReceive(ctx, t, done)
655}

Callers

nothing calls this directly

Calls 8

ContextFunction · 0.92
LoggerFunction · 0.92
TryReceiveFunction · 0.92
newNodeUpdaterFunction · 0.85
closeMethod · 0.65
fillPeerDiagnosticsMethod · 0.45
EqualMethod · 0.45
setNetInfoMethod · 0.45

Tested by

no test coverage detected