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

Function TestDeltaFIFO_addUpdate

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

Source from the content-addressed store, hash-verified

130}
131
132func TestDeltaFIFO_addUpdate(t *testing.T) {
133 f := NewDeltaFIFO(testFifoObjectKeyFunc, nil)
134 f.Add(mkFifoObj("foo", 10))
135 f.Update(mkFifoObj("foo", 12))
136 f.Delete(mkFifoObj("foo", 15))
137
138 if e, a := []interface{}{mkFifoObj("foo", 15)}, f.List(); !reflect.DeepEqual(e, a) {
139 t.Errorf("Expected %+v, got %+v", e, a)
140 }
141 if e, a := []string{"foo"}, f.ListKeys(); !reflect.DeepEqual(e, a) {
142 t.Errorf("Expected %+v, got %+v", e, a)
143 }
144
145 got := make(chan testFifoObject, 2)
146 go func() {
147 for {
148 obj := testPop(f)
149 t.Logf("got a thing %#v", obj)
150 t.Logf("D len: %v", len(f.queue))
151 got <- obj
152 }
153 }()
154
155 first := <-got
156 if e, a := 15, first.val; e != a {
157 t.Errorf("Didn't get updated value (%v), got %v", e, a)
158 }
159 select {
160 case unexpected := <-got:
161 t.Errorf("Got second value %v", unexpected.val)
162 case <-time.After(50 * time.Millisecond):
163 }
164 _, exists, _ := f.Get(mkFifoObj("foo", ""))
165 if exists {
166 t.Errorf("item did not get removed")
167 }
168}
169
170func TestDeltaFIFO_enqueueingNoLister(t *testing.T) {
171 f := NewDeltaFIFO(testFifoObjectKeyFunc, nil)

Callers

nothing calls this directly

Calls 11

AddMethod · 0.95
UpdateMethod · 0.95
DeleteMethod · 0.95
ListMethod · 0.95
ListKeysMethod · 0.95
GetMethod · 0.95
NewDeltaFIFOFunction · 0.85
mkFifoObjFunction · 0.85
testPopFunction · 0.85
ErrorfMethod · 0.65
LogfMethod · 0.65

Tested by

no test coverage detected