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

Function TestFIFO_addReplace

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

Source from the content-addressed store, hash-verified

150}
151
152func TestFIFO_addReplace(t *testing.T) {
153 f := NewFIFO(testFifoObjectKeyFunc)
154 f.Add(mkFifoObj("foo", 10))
155 f.Replace([]interface{}{mkFifoObj("foo", 15)}, "15")
156 got := make(chan testFifoObject, 2)
157 go func() {
158 for {
159 got <- Pop(f).(testFifoObject)
160 }
161 }()
162
163 first := <-got
164 if e, a := 15, first.val; e != a {
165 t.Errorf("Didn't get updated value (%v), got %v", e, a)
166 }
167 select {
168 case unexpected := <-got:
169 t.Errorf("Got second value %v", unexpected.val)
170 case <-time.After(50 * time.Millisecond):
171 }
172 _, exists, _ := f.Get(mkFifoObj("foo", ""))
173 if exists {
174 t.Errorf("item did not get removed")
175 }
176}
177
178func TestFIFO_detectLineJumpers(t *testing.T) {
179 f := NewFIFO(testFifoObjectKeyFunc)

Callers

nothing calls this directly

Calls 7

AddMethod · 0.95
ReplaceMethod · 0.95
GetMethod · 0.95
NewFIFOFunction · 0.85
mkFifoObjFunction · 0.85
PopFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected