/
githubmirror
/
ydb-go-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-go-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
pkg/xtest/clock.go
37 строк
618 B
Aleksey Myasnikov
* Added public package `pkg/xtest` with test helpers (#1850)
17 авг 2025, 18:24
Не верифицирован
17 авг 2025, 18:24
82a8722
Код
Авторство
О чём код?
package xtest import ( "sync/atomic" "testing" "time" "github.com/jonboulle/clockwork" ) // FastClock returns fake clock with very fast time speed advanced until end of test // the clock stops advance at end of test func FastClock(t testing.TB) *clockwork.FakeClock { clock := clockwork.NewFakeClock() var needStop atomic.Bool clockStopped := make(chan struct{}) go func() { defer close(clockStopped) for { if needStop.Load() { return } clock.Advance(time.Second) time.Sleep(time.Microsecond) } }() t.Cleanup(func() { needStop.Store(true) <-clockStopped }) return clock }