chore: update to coder/quartz v0.2.0 (#18007)

Upgrade to coder/quartz v0.2.0 including fixing up a minor API breaking change.
This commit is contained in:
Spike Curtis
2025-05-27 16:05:03 +04:00
committed by GitHub
parent 9ada1232f3
commit 6c0bed0f53
17 changed files with 49 additions and 50 deletions

View File

@ -104,7 +104,7 @@ func TestNotifier(t *testing.T) {
n := notify.New(cond, testCase.PollInterval, testCase.Countdown, notify.WithTestClock(mClock))
defer n.Close()
trap.MustWait(ctx).Release() // ensure ticker started
trap.MustWait(ctx).MustRelease(ctx) // ensure ticker started
for i := 0; i < testCase.NTicks; i++ {
interval, w := mClock.AdvanceNext()
w.MustWait(ctx)

View File

@ -423,7 +423,7 @@ func TestCryptoKeyCache(t *testing.T) {
require.Equal(t, 2, ff.called)
require.Equal(t, decodedSecret(t, newKey), key)
trapped.Release()
trapped.MustRelease(ctx)
wait.MustWait(ctx)
require.Equal(t, 2, ff.called)
trap.Close()

View File

@ -72,7 +72,7 @@ func TestRotator(t *testing.T) {
require.Len(t, dbkeys, initialKeyLen)
requireContainsAllFeatures(t, dbkeys)
trap.MustWait(ctx).Release()
trap.MustWait(ctx).MustRelease(ctx)
_, wait := clock.AdvanceNext()
wait.MustWait(ctx)

View File

@ -279,10 +279,10 @@ func awaitDoTick(ctx context.Context, t *testing.T, clk *quartz.Mock) chan struc
defer trapStop.Close()
defer trapNow.Close()
// Wait for the initial tick signified by a call to Now().
trapNow.MustWait(ctx).Release()
trapNow.MustWait(ctx).MustRelease(ctx)
// doTick runs here. Wait for the next
// ticker reset event that signifies it's completed.
trapReset.MustWait(ctx).Release()
trapReset.MustWait(ctx).MustRelease(ctx)
// Ensure that the next tick happens in 10 minutes from start.
d, w := clk.AdvanceNext()
if !assert.Equal(t, 10*time.Minute, d) {
@ -290,7 +290,7 @@ func awaitDoTick(ctx context.Context, t *testing.T, clk *quartz.Mock) chan struc
}
w.MustWait(ctx)
// Wait for the ticker stop event.
trapStop.MustWait(ctx).Release()
trapStop.MustWait(ctx).MustRelease(ctx)
}()
return ch

View File

@ -32,7 +32,7 @@ func TestWatchdog_NoTimeout(t *testing.T) {
// right baseline time.
pc, err := pubTrap.Wait(ctx)
require.NoError(t, err)
pc.Release()
pc.MustRelease(ctx)
require.Equal(t, 15*time.Second, pc.Duration)
// we subscribe after starting the timer, so we know the timer also starts
@ -66,7 +66,7 @@ func TestWatchdog_NoTimeout(t *testing.T) {
}()
sc, err := subTrap.Wait(ctx) // timer.Stop() called
require.NoError(t, err)
sc.Release()
sc.MustRelease(ctx)
err = testutil.TryReceive(ctx, t, errCh)
require.NoError(t, err)
}
@ -88,7 +88,7 @@ func TestWatchdog_Timeout(t *testing.T) {
// right baseline time.
pc, err := pubTrap.Wait(ctx)
require.NoError(t, err)
pc.Release()
pc.MustRelease(ctx)
require.Equal(t, 15*time.Second, pc.Duration)
// we subscribe after starting the timer, so we know the timer also starts

View File

@ -276,8 +276,8 @@ func TestPendingUpdatesMetric(t *testing.T) {
require.NoError(t, err)
mgr.Run(ctx)
trap.MustWait(ctx).Release() // ensures ticker has been set
fetchTrap.MustWait(ctx).Release()
trap.MustWait(ctx).MustRelease(ctx) // ensures ticker has been set
fetchTrap.MustWait(ctx).MustRelease(ctx)
// Advance to the first fetch
mClock.Advance(cfg.FetchInterval.Value()).MustWait(ctx)

View File

@ -341,8 +341,8 @@ func TestBackpressure(t *testing.T) {
// Start the notifier.
mgr.Run(ctx)
syncTrap.MustWait(ctx).Release()
fetchTrap.MustWait(ctx).Release()
syncTrap.MustWait(ctx).MustRelease(ctx)
fetchTrap.MustWait(ctx).MustRelease(ctx)
// THEN: