« All posts

Test a one-hour timeout without waiting an hour

Utilize Go 1.25's testing/synctest for efficient concurrent testing with virtual time.

The Go 1.25 feature testing/synctest introduces virtual time for concurrent tests, allowing production code to continue using standard time packages without modification. This means a test with a one-hour context deadline can complete in 0.00 seconds, as the clock advances while all goroutines are durably blocked. This feature is particularly useful for testing asynchronous behavior, such as retries and rate limiters, while complementing integration testing and the race detector.