MCPcopy
hub / github.com/kubernetes/client-go / TestFIFO_HasSynced

Function TestFIFO_HasSynced

tools/cache/fifo_test.go:226–280  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

224}
225
226func TestFIFO_HasSynced(t *testing.T) {
227 tests := []struct {
228 actions []func(f *FIFO)
229 expectedSynced bool
230 }{
231 {
232 actions: []func(f *FIFO){},
233 expectedSynced: false,
234 },
235 {
236 actions: []func(f *FIFO){
237 func(f *FIFO) { f.Add(mkFifoObj("a", 1)) },
238 },
239 expectedSynced: true,
240 },
241 {
242 actions: []func(f *FIFO){
243 func(f *FIFO) { f.Replace([]interface{}{}, "0") },
244 },
245 expectedSynced: true,
246 },
247 {
248 actions: []func(f *FIFO){
249 func(f *FIFO) { f.Replace([]interface{}{mkFifoObj("a", 1), mkFifoObj("b", 2)}, "0") },
250 },
251 expectedSynced: false,
252 },
253 {
254 actions: []func(f *FIFO){
255 func(f *FIFO) { f.Replace([]interface{}{mkFifoObj("a", 1), mkFifoObj("b", 2)}, "0") },
256 func(f *FIFO) { Pop(f) },
257 },
258 expectedSynced: false,
259 },
260 {
261 actions: []func(f *FIFO){
262 func(f *FIFO) { f.Replace([]interface{}{mkFifoObj("a", 1), mkFifoObj("b", 2)}, "0") },
263 func(f *FIFO) { Pop(f) },
264 func(f *FIFO) { Pop(f) },
265 },
266 expectedSynced: true,
267 },
268 }
269
270 for i, test := range tests {
271 f := NewFIFO(testFifoObjectKeyFunc)
272
273 for _, action := range test.actions {
274 action(f)
275 }
276 if e, a := test.expectedSynced, f.HasSynced(); a != e {
277 t.Errorf("test case %v failed, expected: %v , got %v", i, e, a)
278 }
279 }
280}

Callers

nothing calls this directly

Calls 7

AddMethod · 0.95
ReplaceMethod · 0.95
HasSyncedMethod · 0.95
mkFifoObjFunction · 0.85
PopFunction · 0.85
NewFIFOFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected