mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
cacher/cacher_whitebox_test: newTestCacherWithoutSyncing allow passing a clock
This commit is contained in:
parent
2bda5dd8c7
commit
cfd6d9a2b4
@ -61,7 +61,7 @@ import (
|
|||||||
"k8s.io/utils/pointer"
|
"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"
|
prefix := "pods"
|
||||||
config := Config{
|
config := Config{
|
||||||
Storage: s,
|
Storage: s,
|
||||||
@ -85,7 +85,7 @@ func newTestCacherWithoutSyncing(s storage.Interface) (*Cacher, storage.Versione
|
|||||||
NewFunc: func() runtime.Object { return &example.Pod{} },
|
NewFunc: func() runtime.Object { return &example.Pod{} },
|
||||||
NewListFunc: func() runtime.Object { return &example.PodList{} },
|
NewListFunc: func() runtime.Object { return &example.PodList{} },
|
||||||
Codec: codecs.LegacyCodec(examplev1.SchemeGroupVersion),
|
Codec: codecs.LegacyCodec(examplev1.SchemeGroupVersion),
|
||||||
Clock: clock.RealClock{},
|
Clock: c,
|
||||||
}
|
}
|
||||||
cacher, err := NewCacherFromConfig(config)
|
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) {
|
func newTestCacher(s storage.Interface) (*Cacher, storage.Versioner, error) {
|
||||||
cacher, versioner, err := newTestCacherWithoutSyncing(s)
|
cacher, versioner, err := newTestCacherWithoutSyncing(s, clock.RealClock{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, versioner, err
|
return nil, versioner, err
|
||||||
}
|
}
|
||||||
@ -625,7 +625,7 @@ func TestTooManyRequestsNotReturned(t *testing.T) {
|
|||||||
|
|
||||||
dummyErr := fmt.Errorf("dummy")
|
dummyErr := fmt.Errorf("dummy")
|
||||||
backingStorage := &dummyStorage{err: dummyErr}
|
backingStorage := &dummyStorage{err: dummyErr}
|
||||||
cacher, _, err := newTestCacherWithoutSyncing(backingStorage)
|
cacher, _, err := newTestCacherWithoutSyncing(backingStorage, clock.RealClock{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Couldn't create cacher: %v", err)
|
t.Fatalf("Couldn't create cacher: %v", err)
|
||||||
}
|
}
|
||||||
@ -752,7 +752,7 @@ func TestWatchNotHangingOnStartupFailure(t *testing.T) {
|
|||||||
// constantly failing lists to the underlying storage.
|
// constantly failing lists to the underlying storage.
|
||||||
dummyErr := fmt.Errorf("dummy")
|
dummyErr := fmt.Errorf("dummy")
|
||||||
backingStorage := &dummyStorage{err: dummyErr}
|
backingStorage := &dummyStorage{err: dummyErr}
|
||||||
cacher, _, err := newTestCacherWithoutSyncing(backingStorage)
|
cacher, _, err := newTestCacherWithoutSyncing(backingStorage, clock.RealClock{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Couldn't create cacher: %v", err)
|
t.Fatalf("Couldn't create cacher: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user