Files
lo/internal/xtime/time.go
T
Samuel Berthe 380e1a0ae2 fix(tests): fix flaky time-based tests (#699)
* fix(tests): fix flaky time-based tests

* test: replace time package with a mock
Using a dedicated dependency would have been awesome, but i try to keep this repo with minimal dependencies
2025-10-05 00:34:07 +02:00

34 lines
478 B
Go

//nolint:revive
package xtime
import "time"
var clock Clock = &RealClock{}
func SetClock(c Clock) {
clock = c
}
func Now() time.Time {
return clock.Now()
}
func Since(t time.Time) time.Duration {
return clock.Since(t)
}
func Until(t time.Time) time.Duration {
return clock.Until(t)
}
func Sleep(d time.Duration) {
clock.Sleep(d)
}
type Clock interface {
Now() time.Time
Since(t time.Time) time.Duration
Until(t time.Time) time.Duration
Sleep(d time.Duration)
}