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

Function TestHeap_GetByKey

tools/cache/heap_test.go:273–289  ·  view source on GitHub ↗

TestHeap_GetByKey tests Heap.GetByKey and is very similar to TestHeap_Get.

(t *testing.T)

Source from the content-addressed store, hash-verified

271
272// TestHeap_GetByKey tests Heap.GetByKey and is very similar to TestHeap_Get.
273func TestHeap_GetByKey(t *testing.T) {
274 h := NewHeap(testHeapObjectKeyFunc, compareInts)
275 h.Add(mkHeapObj("foo", 10))
276 h.Add(mkHeapObj("bar", 1))
277 h.Add(mkHeapObj("bal", 31))
278 h.Add(mkHeapObj("baz", 11))
279
280 obj, exists, err := h.GetByKey("baz")
281 if err != nil || exists == false || obj.(testHeapObject).val != 11 {
282 t.Fatalf("unexpected error in getting element")
283 }
284 // Get non-existing object.
285 _, exists, err = h.GetByKey("non-existing")
286 if err != nil || exists == true {
287 t.Fatalf("didn't expect to get any object")
288 }
289}
290
291// TestHeap_Close tests Heap.Close and Heap.IsClosed functions.
292func TestHeap_Close(t *testing.T) {

Callers

nothing calls this directly

Calls 4

AddMethod · 0.95
GetByKeyMethod · 0.95
NewHeapFunction · 0.85
mkHeapObjFunction · 0.85

Tested by

no test coverage detected