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

Function TestDeltaFIFO_basic

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

Source from the content-addressed store, hash-verified

51}
52
53func TestDeltaFIFO_basic(t *testing.T) {
54 f := NewDeltaFIFO(testFifoObjectKeyFunc, nil)
55 const amount = 500
56 go func() {
57 for i := 0; i < amount; i++ {
58 f.Add(mkFifoObj(string([]rune{'a', rune(i)}), i+1))
59 }
60 }()
61 go func() {
62 for u := uint64(0); u < amount; u++ {
63 f.Add(mkFifoObj(string([]rune{'b', rune(u)}), u+1))
64 }
65 }()
66
67 lastInt := int(0)
68 lastUint := uint64(0)
69 for i := 0; i < amount*2; i++ {
70 switch obj := testPop(f).val.(type) {
71 case int:
72 if obj <= lastInt {
73 t.Errorf("got %v (int) out of order, last was %v", obj, lastInt)
74 }
75 lastInt = obj
76 case uint64:
77 if obj <= lastUint {
78 t.Errorf("got %v (uint) out of order, last was %v", obj, lastUint)
79 } else {
80 lastUint = obj
81 }
82 default:
83 t.Fatalf("unexpected type %#v", obj)
84 }
85 }
86}
87
88func TestDeltaFIFO_requeueOnPop(t *testing.T) {
89 f := NewDeltaFIFO(testFifoObjectKeyFunc, nil)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected