Skip to content

Commit

Permalink
use BlockUntilContext
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Feb 10, 2025
1 parent a0c3dc0 commit 6180765
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/compose/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func TestDebounceBatching(t *testing.T) {
ch <- *event
}
// we sent 100 events + the debouncer
clock.BlockUntil(101)
err := clock.BlockUntilContext(ctx, 101)
assert.NilError(t, err)
clock.Advance(quietPeriod)
select {
case batch := <-eventBatchCh:
Expand All @@ -73,7 +74,8 @@ func TestDebounceBatching(t *testing.T) {
case <-time.After(50 * time.Millisecond):
t.Fatal("timed out waiting for events")
}
clock.BlockUntil(1)
err = clock.BlockUntilContext(ctx, 1)
assert.NilError(t, err)
clock.Advance(quietPeriod)

// there should only be a single batch
Expand Down Expand Up @@ -191,7 +193,8 @@ func TestWatch_Sync(t *testing.T) {

watcher.Events() <- watch.NewFileEvent("/sync/changed")
watcher.Events() <- watch.NewFileEvent("/sync/changed/sub")
clock.BlockUntil(3)
err := clock.BlockUntilContext(ctx, 3)
assert.NilError(t, err)
clock.Advance(quietPeriod)
select {
case actual := <-syncer.synced:
Expand All @@ -206,7 +209,8 @@ func TestWatch_Sync(t *testing.T) {
watcher.Events() <- watch.NewFileEvent("/sync/ignore")
watcher.Events() <- watch.NewFileEvent("/sync/ignore/sub")
watcher.Events() <- watch.NewFileEvent("/sync/changed")
clock.BlockUntil(4)
err = clock.BlockUntilContext(ctx, 4)
assert.NilError(t, err)
clock.Advance(quietPeriod)
select {
case actual := <-syncer.synced:
Expand All @@ -219,7 +223,8 @@ func TestWatch_Sync(t *testing.T) {

watcher.Events() <- watch.NewFileEvent("/rebuild")
watcher.Events() <- watch.NewFileEvent("/sync/changed")
clock.BlockUntil(4)
err = clock.BlockUntilContext(ctx, 4)
assert.NilError(t, err)
clock.Advance(quietPeriod)
select {
case batch := <-syncer.synced:
Expand Down

0 comments on commit 6180765

Please sign in to comment.