diff --git a/event/event_test.go b/event/event_test.go index 5b7b3b9..a477504 100644 --- a/event/event_test.go +++ b/event/event_test.go @@ -89,9 +89,8 @@ func (r *receiver) waitFor(want int, timeout time.Duration) (map[terminalapi.Eve ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - tick := time.NewTimer(5 * time.Millisecond) - defer tick.Stop() for { + tick := time.NewTimer(5 * time.Millisecond) select { case <-tick.C: ev := r.getEvents() @@ -106,7 +105,7 @@ func (r *receiver) waitFor(want int, timeout time.Duration) (map[terminalapi.Eve case <-ctx.Done(): ev := r.getEvents() - return nil, fmt.Errorf("while waiting for events, got %d so far: %v, err: %v", len(ev), ev, ctx.Err()) + return nil, fmt.Errorf("while waiting for events, got %d so far: %v, want %d, err: %v", len(ev), ev, want, ctx.Err()) } } } diff --git a/termdash_test.go b/termdash_test.go index 51be414..13f9dcb 100644 --- a/termdash_test.go +++ b/termdash_test.go @@ -564,9 +564,8 @@ func untilEmpty(timeout time.Duration, q *eventqueue.Unbound) error { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - tick := time.NewTimer(5 * time.Millisecond) - defer tick.Stop() for { + tick := time.NewTimer(5 * time.Millisecond) select { case <-tick.C: if q.Empty() {