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

Function TestDeltaFIFO_addReplace

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

Source from the content-addressed store, hash-verified

213}
214
215func TestDeltaFIFO_addReplace(t *testing.T) {
216 f := NewDeltaFIFO(testFifoObjectKeyFunc, nil)
217 f.Add(mkFifoObj("foo", 10))
218 f.Replace([]interface{}{mkFifoObj("foo", 15)}, "0")
219 got := make(chan testFifoObject, 2)
220 go func() {
221 for {
222 got <- testPop(f)
223 }
224 }()
225
226 first := <-got
227 if e, a := 15, first.val; e != a {
228 t.Errorf("Didn't get updated value (%v), got %v", e, a)
229 }
230 select {
231 case unexpected := <-got:
232 t.Errorf("Got second value %v", unexpected.val)
233 case <-time.After(50 * time.Millisecond):
234 }
235 _, exists, _ := f.Get(mkFifoObj("foo", ""))
236 if exists {
237 t.Errorf("item did not get removed")
238 }
239}
240
241func TestDeltaFIFO_ResyncNonExisting(t *testing.T) {
242 f := NewDeltaFIFO(

Callers

nothing calls this directly

Calls 7

AddMethod · 0.95
ReplaceMethod · 0.95
GetMethod · 0.95
NewDeltaFIFOFunction · 0.85
mkFifoObjFunction · 0.85
testPopFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected