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

Function TestFIFO_addIfNotPresent

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

Source from the content-addressed store, hash-verified

204}
205
206func TestFIFO_addIfNotPresent(t *testing.T) {
207 f := NewFIFO(testFifoObjectKeyFunc)
208
209 f.Add(mkFifoObj("a", 1))
210 f.Add(mkFifoObj("b", 2))
211 f.AddIfNotPresent(mkFifoObj("b", 3))
212 f.AddIfNotPresent(mkFifoObj("c", 4))
213
214 if e, a := 3, len(f.items); a != e {
215 t.Fatalf("expected queue length %d, got %d", e, a)
216 }
217
218 expectedValues := []int{1, 2, 4}
219 for _, expected := range expectedValues {
220 if actual := Pop(f).(testFifoObject).val; actual != expected {
221 t.Fatalf("expected value %d, got %d", expected, actual)
222 }
223 }
224}
225
226func TestFIFO_HasSynced(t *testing.T) {
227 tests := []struct {

Callers

nothing calls this directly

Calls 5

AddMethod · 0.95
AddIfNotPresentMethod · 0.95
NewFIFOFunction · 0.85
mkFifoObjFunction · 0.85
PopFunction · 0.85

Tested by

no test coverage detected