MCPcopy
hub / github.com/tailscale/tailscale / TestMonitorInjectEvent

Function TestMonitorInjectEvent

net/netmon/netmon_test.go:48–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestMonitorInjectEvent(t *testing.T) {
49 bus := eventbus.New()
50 defer bus.Close()
51
52 mon, err := New(bus, t.Logf)
53 if err != nil {
54 t.Fatal(err)
55 }
56 defer mon.Close()
57 got := make(chan bool, 1)
58 mon.RegisterChangeCallback(func(*ChangeDelta) {
59 select {
60 case got <- true:
61 default:
62 }
63 })
64 mon.Start()
65 mon.InjectEvent()
66 select {
67 case <-got:
68 // Pass.
69 case <-time.After(5 * time.Second):
70 t.Fatal("timeout waiting for callback")
71 }
72}
73
74func TestMonitorInjectEventOnBus(t *testing.T) {
75 bus := eventbustest.NewBus(t)

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
InjectEventMethod · 0.80
AfterMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65
FatalMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…