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

Function TestDeltaFIFO_ReplaceMakesDeletions

tools/cache/delta_fifo_test.go:279–303  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestDeltaFIFO_ReplaceMakesDeletions(t *testing.T) {
280 f := NewDeltaFIFO(
281 testFifoObjectKeyFunc,
282 keyLookupFunc(func() []testFifoObject {
283 return []testFifoObject{mkFifoObj("foo", 5), mkFifoObj("bar", 6), mkFifoObj("baz", 7)}
284 }),
285 )
286 f.Delete(mkFifoObj("baz", 10))
287 f.Replace([]interface{}{mkFifoObj("foo", 5)}, "0")
288
289 expectedList := []Deltas{
290 {{Deleted, mkFifoObj("baz", 10)}},
291 {{Sync, mkFifoObj("foo", 5)}},
292 // Since "bar" didn't have a delete event and wasn't in the Replace list
293 // it should get a tombstone key with the right Obj.
294 {{Deleted, DeletedFinalStateUnknown{Key: "bar", Obj: mkFifoObj("bar", 6)}}},
295 }
296
297 for _, expected := range expectedList {
298 cur := Pop(f).(Deltas)
299 if e, a := expected, cur; !reflect.DeepEqual(e, a) {
300 t.Errorf("Expected %#v, got %#v", e, a)
301 }
302 }
303}
304
305func TestDeltaFIFO_UpdateResyncRace(t *testing.T) {
306 f := NewDeltaFIFO(

Callers

nothing calls this directly

Calls 7

DeleteMethod · 0.95
ReplaceMethod · 0.95
NewDeltaFIFOFunction · 0.85
keyLookupFuncFuncType · 0.85
mkFifoObjFunction · 0.85
PopFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected