MCPcopy
hub / github.com/SpecterOps/BloodHound / getPopulatedInstance

Function getPopulatedInstance

packages/go/cache/cache_test.go:55–69  ·  view source on GitHub ↗
(data cacheFillHarness)

Source from the content-addressed store, hash-verified

53type cacheFillHarness map[string]testStruct
54
55func getPopulatedInstance(data cacheFillHarness) (cache.Cache, error) {
56 if instance, err := cache.NewCache(cache.Config{len(data)}); err != nil {
57 return instance, fmt.Errorf("failed to create new cache instance: %w", err)
58 } else {
59 for key, value := range data {
60 if _, evicted, err := instance.Set(key, value); err != nil {
61 return instance, fmt.Errorf("failed to set value %+v to key %s: %w", value, key, err)
62 } else if evicted {
63 return instance, fmt.Errorf("failed to set value %+v to key %s: an unexpected eviction occurred", value, key)
64 }
65 }
66
67 return instance, nil
68 }
69}
70
71func TestCache_NewCache(t *testing.T) {
72 var (

Callers 3

TestCache_SetFunction · 0.85
TestCache_GetFunction · 0.85
TestCache_ResetFunction · 0.85

Calls 3

SetMethod · 0.95
NewCacheFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected