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 4622970 commit ed7f692
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pkg/compose/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,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(watch.QuietPeriod)
select {
case actual := <-syncer.synced:
Expand All @@ -161,7 +162,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(watch.QuietPeriod)
select {
case batch := <-syncer.synced:
Expand Down
6 changes: 4 additions & 2 deletions pkg/watch/debounce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func Test_BatchDebounceEvents(t *testing.T) {
ch <- FileEvent(path)
}
// 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 @@ -51,7 +52,8 @@ func Test_BatchDebounceEvents(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

0 comments on commit ed7f692

Please sign in to comment.