mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-19 06:02:57 +00:00
health: remove direct callback and replace with eventbus (#17199)
Pulls out the last callback logic and ensures timers are still running. The eventbustest package is updated support the absence of events. Updates #15160 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
@@ -120,7 +120,12 @@ func Expect(tw *Watcher, filters ...any) error {
|
||||
// [Expect]. Use [Expect] if other events are allowed.
|
||||
func ExpectExactly(tw *Watcher, filters ...any) error {
|
||||
if len(filters) == 0 {
|
||||
return errors.New("no event filters were provided")
|
||||
select {
|
||||
case event := <-tw.events:
|
||||
return fmt.Errorf("saw event type %s, expected none", reflect.TypeOf(event))
|
||||
case <-time.After(tw.TimeOut):
|
||||
return nil
|
||||
}
|
||||
}
|
||||
eventCount := 0
|
||||
for pos, next := range filters {
|
||||
|
@@ -250,7 +250,7 @@ func TestExpectEvents(t *testing.T) {
|
||||
tw := eventbustest.NewWatcher(t, bus)
|
||||
// TODO(cmol): When synctest is out of experimental, use that instead:
|
||||
// https://go.dev/blog/synctest
|
||||
tw.TimeOut = 10 * time.Millisecond
|
||||
tw.TimeOut = 100 * time.Millisecond
|
||||
|
||||
client := bus.Client("testClient")
|
||||
defer client.Close()
|
||||
|
Reference in New Issue
Block a user