Skip to content

chore: add explicit Wait() to clock.Advance() #13464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented Jun 4, 2024

Modifies clock.Mock.Advance() to allow explicitly waiting for advance to complete. E.g.

mClock.Advance(time.Second).MustWait(ctx, t)

Having the wait be explicit allows you to more easily write tests where the timer or ticker calls back into the clock with something you have a trap set for, e.g.

w := mClock.Advance(time.Second)
c, err := trap.Wait(ctx)
require.NoError(t, err)
c.Release()
w.MustWait(ctx, t)

Copy link
Contributor Author

spikecurtis commented Jun 4, 2024

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 I'm assuming the linter complaints are due to stacking.

@spikecurtis spikecurtis force-pushed the spike/clock-testing-watchdog branch from e243711 to 63c9374 Compare June 5, 2024 06:14
@spikecurtis spikecurtis force-pushed the spike/clock-testing-explicit-wait branch from 1f3c4aa to b55fc1a Compare June 5, 2024 06:14
Base automatically changed from spike/clock-testing-watchdog to main June 5, 2024 09:55
@spikecurtis spikecurtis force-pushed the spike/clock-testing-explicit-wait branch from b55fc1a to 35daa55 Compare June 5, 2024 09:56
@spikecurtis spikecurtis force-pushed the spike/clock-testing-explicit-wait branch from 35daa55 to 6e5decd Compare June 5, 2024 10:01
@spikecurtis spikecurtis merged commit 9c3fd5d into main Jun 5, 2024
27 checks passed
@spikecurtis spikecurtis deleted the spike/clock-testing-explicit-wait branch June 5, 2024 11:37
Copy link
Contributor Author

Merge activity

@github-actions github-actions bot locked and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants