tstest: prepare for Clock API changes

This change introduces tstime.NewClock and tstime.ClockOpts as a new way
to construct tstime.Clock. This is a subset of #8464 as a stepping stone
so that we can update our internal code to use the new API before making
the second round of changes.

Updates #8463

Change-Id: Ib26edb60e5355802aeca83ed60e4fdf806c90e27
Signed-off-by: Adrian Dewhurst <adrian@tailscale.com>
This commit is contained in:
Adrian Dewhurst
2023-07-06 16:09:24 -04:00
committed by Adrian Dewhurst
parent fd8c8a3700
commit cd4c71c122
4 changed files with 95 additions and 21 deletions

View File

@@ -18,9 +18,9 @@ import (
)
func TestMessageCache(t *testing.T) {
clock := &tstest.Clock{
clock := tstest.NewClock(tstest.ClockOpts{
Start: time.Date(1987, 11, 1, 0, 0, 0, 0, time.UTC),
}
})
mc := &MessageCache{Clock: clock.Now}
mc.SetMaxCacheSize(2)
clock.Advance(time.Second)