MCPcopy
hub / github.com/gofiber/fiber / Test_indexedHeap_PushAndOps

Function Test_indexedHeap_PushAndOps

middleware/cache/coverage_test.go:279–305  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func Test_indexedHeap_PushAndOps(t *testing.T) {
280 t.Parallel()
281
282 h := &indexedHeap{}
283
284 // put inserts entries and returns tracking indices.
285 idxA := h.put("a", 30, 1)
286 idxB := h.put("b", 10, 2)
287 idxC := h.put("c", 20, 3)
288 require.Equal(t, 3, h.Len())
289
290 // The lowest expiration must come out first.
291 key, _ := h.removeFirst()
292 require.Equal(t, "b", key)
293
294 // Remove an arbitrary tracked entry.
295 key, _ = h.remove(idxC)
296 require.Equal(t, "c", key)
297 _ = idxA
298 _ = idxB
299
300 // Directly exercise the heap.Interface Push method (not used by put()).
301 h2 := &indexedHeap{indices: []int{0}}
302 heap.Push(h2, heapEntry{key: "z", exp: 5, idx: 0})
303 require.Equal(t, 1, h2.Len())
304 require.Equal(t, "z", h2.entries[0].key)
305}
306
307func Test_parseUintDirective(t *testing.T) {
308 t.Parallel()

Callers

nothing calls this directly

Calls 5

putMethod · 0.95
LenMethod · 0.95
removeFirstMethod · 0.95
removeMethod · 0.95
PushMethod · 0.80

Tested by

no test coverage detected