cacher/cacher_whitebox_test: newTestCacherWithoutSyncing allow passing a clock

This commit is contained in:
Lukasz Szaszkiewicz 2025-01-27 19:51:35 +01:00
parent 2bda5dd8c7
commit cfd6d9a2b4

View File

@ -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)
}