MCPcopy Create free account
hub / github.com/allegro/bigcache / TestEntriesIterator

Function TestEntriesIterator

iterator_test.go:14–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestEntriesIterator(t *testing.T) {
15 t.Parallel()
16
17 // given
18 keysCount := 1000
19 cache, _ := New(context.Background(), Config{
20 Shards: 8,
21 LifeWindow: 6 * time.Second,
22 MaxEntriesInWindow: 1,
23 MaxEntrySize: 256,
24 })
25 value := []byte("value")
26
27 for i := 0; i < keysCount; i++ {
28 cache.Set(fmt.Sprintf("key%d", i), value)
29 }
30
31 // when
32 keys := make(map[string]struct{})
33 iterator := cache.Iterator()
34
35 for iterator.SetNext() {
36 current, err := iterator.Value()
37
38 if err == nil {
39 keys[current.Key()] = struct{}{}
40 }
41 }
42
43 // then
44 assertEqual(t, keysCount, len(keys))
45}
46
47func TestEntriesIteratorWithMostShardsEmpty(t *testing.T) {
48 t.Parallel()

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
SetMethod · 0.80
IteratorMethod · 0.80
SetNextMethod · 0.80
KeyMethod · 0.80
assertEqualFunction · 0.70
ValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…