From cfd6d9a2b4476d4256959dc2ebdd517f20191ea3 Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Mon, 27 Jan 2025 19:51:35 +0100 Subject: [PATCH] cacher/cacher_whitebox_test: newTestCacherWithoutSyncing allow passing a clock --- .../pkg/storage/cacher/cacher_whitebox_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go index 5378560a6f4..ed9394193c0 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go @@ -61,7 +61,7 @@ import ( "k8s.io/utils/pointer" ) -func newTestCacherWithoutSyncing(s storage.Interface) (*Cacher, storage.Versioner, error) { +func newTestCacherWithoutSyncing(s storage.Interface, c clock.WithTicker) (*Cacher, storage.Versioner, error) { prefix := "pods" config := Config{ Storage: s, @@ -85,7 +85,7 @@ func newTestCacherWithoutSyncing(s storage.Interface) (*Cacher, storage.Versione NewFunc: func() runtime.Object { return &example.Pod{} }, NewListFunc: func() runtime.Object { return &example.PodList{} }, Codec: codecs.LegacyCodec(examplev1.SchemeGroupVersion), - Clock: clock.RealClock{}, + Clock: c, } cacher, err := NewCacherFromConfig(config) @@ -93,7 +93,7 @@ func newTestCacherWithoutSyncing(s storage.Interface) (*Cacher, storage.Versione } func newTestCacher(s storage.Interface) (*Cacher, storage.Versioner, error) { - cacher, versioner, err := newTestCacherWithoutSyncing(s) + cacher, versioner, err := newTestCacherWithoutSyncing(s, clock.RealClock{}) if err != nil { return nil, versioner, err } @@ -625,7 +625,7 @@ func TestTooManyRequestsNotReturned(t *testing.T) { dummyErr := fmt.Errorf("dummy") backingStorage := &dummyStorage{err: dummyErr} - cacher, _, err := newTestCacherWithoutSyncing(backingStorage) + cacher, _, err := newTestCacherWithoutSyncing(backingStorage, clock.RealClock{}) if err != nil { t.Fatalf("Couldn't create cacher: %v", err) } @@ -752,7 +752,7 @@ func TestWatchNotHangingOnStartupFailure(t *testing.T) { // constantly failing lists to the underlying storage. dummyErr := fmt.Errorf("dummy") backingStorage := &dummyStorage{err: dummyErr} - cacher, _, err := newTestCacherWithoutSyncing(backingStorage) + cacher, _, err := newTestCacherWithoutSyncing(backingStorage, clock.RealClock{}) if err != nil { t.Fatalf("Couldn't create cacher: %v", err) }