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

Function TestDeltaFIFO_addIfNotPresent

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

Source from the content-addressed store, hash-verified

384}
385
386func TestDeltaFIFO_addIfNotPresent(t *testing.T) {
387 f := NewDeltaFIFO(testFifoObjectKeyFunc, nil)
388
389 f.Add(mkFifoObj("b", 3))
390 b3 := Pop(f)
391 f.Add(mkFifoObj("c", 4))
392 c4 := Pop(f)
393 if e, a := 0, len(f.items); e != a {
394 t.Fatalf("Expected %v, got %v items in queue", e, a)
395 }
396
397 f.Add(mkFifoObj("a", 1))
398 f.Add(mkFifoObj("b", 2))
399 f.AddIfNotPresent(b3)
400 f.AddIfNotPresent(c4)
401
402 if e, a := 3, len(f.items); a != e {
403 t.Fatalf("expected queue length %d, got %d", e, a)
404 }
405
406 expectedValues := []int{1, 2, 4}
407 for _, expected := range expectedValues {
408 if actual := testPop(f).val; actual != expected {
409 t.Fatalf("expected value %d, got %d", expected, actual)
410 }
411 }
412}
413
414func TestDeltaFIFO_KeyOf(t *testing.T) {
415 f := DeltaFIFO{keyFunc: testFifoObjectKeyFunc}

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
AddIfNotPresentMethod · 0.95
NewDeltaFIFOFunction · 0.85
mkFifoObjFunction · 0.85
PopFunction · 0.85
testPopFunction · 0.85

Tested by

no test coverage detected