Skip to content

Commit cfd6d9a

Browse files
committed
cacher/cacher_whitebox_test: newTestCacherWithoutSyncing allow passing a clock
1 parent 2bda5dd commit cfd6d9a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import (
6161
"k8s.io/utils/pointer"
6262
)
6363

64-
func newTestCacherWithoutSyncing(s storage.Interface) (*Cacher, storage.Versioner, error) {
64+
func newTestCacherWithoutSyncing(s storage.Interface, c clock.WithTicker) (*Cacher, storage.Versioner, error) {
6565
prefix := "pods"
6666
config := Config{
6767
Storage: s,
@@ -85,15 +85,15 @@ func newTestCacherWithoutSyncing(s storage.Interface) (*Cacher, storage.Versione
8585
NewFunc: func() runtime.Object { return &example.Pod{} },
8686
NewListFunc: func() runtime.Object { return &example.PodList{} },
8787
Codec: codecs.LegacyCodec(examplev1.SchemeGroupVersion),
88-
Clock: clock.RealClock{},
88+
Clock: c,
8989
}
9090
cacher, err := NewCacherFromConfig(config)
9191

9292
return cacher, storage.APIObjectVersioner{}, err
9393
}
9494

9595
func newTestCacher(s storage.Interface) (*Cacher, storage.Versioner, error) {
96-
cacher, versioner, err := newTestCacherWithoutSyncing(s)
96+
cacher, versioner, err := newTestCacherWithoutSyncing(s, clock.RealClock{})
9797
if err != nil {
9898
return nil, versioner, err
9999
}
@@ -625,7 +625,7 @@ func TestTooManyRequestsNotReturned(t *testing.T) {
625625

626626
dummyErr := fmt.Errorf("dummy")
627627
backingStorage := &dummyStorage{err: dummyErr}
628-
cacher, _, err := newTestCacherWithoutSyncing(backingStorage)
628+
cacher, _, err := newTestCacherWithoutSyncing(backingStorage, clock.RealClock{})
629629
if err != nil {
630630
t.Fatalf("Couldn't create cacher: %v", err)
631631
}
@@ -752,7 +752,7 @@ func TestWatchNotHangingOnStartupFailure(t *testing.T) {
752752
// constantly failing lists to the underlying storage.
753753
dummyErr := fmt.Errorf("dummy")
754754
backingStorage := &dummyStorage{err: dummyErr}
755-
cacher, _, err := newTestCacherWithoutSyncing(backingStorage)
755+
cacher, _, err := newTestCacherWithoutSyncing(backingStorage, clock.RealClock{})
756756
if err != nil {
757757
t.Fatalf("Couldn't create cacher: %v", err)
758758
}

0 commit comments

Comments
 (0)