...
1
16
17 package cache
18
19
20 type FakeCustomStore struct {
21 AddFunc func(obj interface{}) error
22 UpdateFunc func(obj interface{}) error
23 DeleteFunc func(obj interface{}) error
24 ListFunc func() []interface{}
25 ListKeysFunc func() []string
26 GetFunc func(obj interface{}) (item interface{}, exists bool, err error)
27 GetByKeyFunc func(key string) (item interface{}, exists bool, err error)
28 ReplaceFunc func(list []interface{}, resourceVersion string) error
29 ResyncFunc func() error
30 }
31
32
33 func (f *FakeCustomStore) Add(obj interface{}) error {
34 if f.AddFunc != nil {
35 return f.AddFunc(obj)
36 }
37 return nil
38 }
39
40
41 func (f *FakeCustomStore) Update(obj interface{}) error {
42 if f.UpdateFunc != nil {
43 return f.UpdateFunc(obj)
44 }
45 return nil
46 }
47
48
49 func (f *FakeCustomStore) Delete(obj interface{}) error {
50 if f.DeleteFunc != nil {
51 return f.DeleteFunc(obj)
52 }
53 return nil
54 }
55
56
57 func (f *FakeCustomStore) List() []interface{} {
58 if f.ListFunc != nil {
59 return f.ListFunc()
60 }
61 return nil
62 }
63
64
65 func (f *FakeCustomStore) ListKeys() []string {
66 if f.ListKeysFunc != nil {
67 return f.ListKeysFunc()
68 }
69 return nil
70 }
71
72
73 func (f *FakeCustomStore) Get(obj interface{}) (item interface{}, exists bool, err error) {
74 if f.GetFunc != nil {
75 return f.GetFunc(obj)
76 }
77 return nil, false, nil
78 }
79
80
81 func (f *FakeCustomStore) GetByKey(key string) (item interface{}, exists bool, err error) {
82 if f.GetByKeyFunc != nil {
83 return f.GetByKeyFunc(key)
84 }
85 return nil, false, nil
86 }
87
88
89 func (f *FakeCustomStore) Replace(list []interface{}, resourceVersion string) error {
90 if f.ReplaceFunc != nil {
91 return f.ReplaceFunc(list, resourceVersion)
92 }
93 return nil
94 }
95
96
97 func (f *FakeCustomStore) Resync() error {
98 if f.ResyncFunc != nil {
99 return f.ResyncFunc()
100 }
101 return nil
102 }
103
View as plain text