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

Function TestEntriesIteratorWithMostShardsEmpty

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

Source from the content-addressed store, hash-verified

45}
46
47func TestEntriesIteratorWithMostShardsEmpty(t *testing.T) {
48 t.Parallel()
49
50 // given
51 clock := mockedClock{value: 0}
52 cache, _ := newBigCache(context.Background(), Config{
53 Shards: 8,
54 LifeWindow: 6 * time.Second,
55 MaxEntriesInWindow: 1,
56 MaxEntrySize: 256,
57 }, &clock)
58
59 cache.Set("key", []byte("value"))
60
61 // when
62 iterator := cache.Iterator()
63
64 // then
65 if !iterator.SetNext() {
66 t.Errorf("Iterator should contain at least single element")
67 }
68
69 current, err := iterator.Value()
70
71 // then
72 noError(t, err)
73 assertEqual(t, "key", current.Key())
74 assertEqual(t, uint64(0x3dc94a19365b10ec), current.Hash())
75 assertEqual(t, []byte("value"), current.Value())
76 assertEqual(t, uint64(0), current.Timestamp())
77}
78
79func TestEntriesIteratorWithConcurrentUpdate(t *testing.T) {
80 t.Parallel()

Callers

nothing calls this directly

Calls 10

newBigCacheFunction · 0.85
SetMethod · 0.80
IteratorMethod · 0.80
SetNextMethod · 0.80
KeyMethod · 0.80
HashMethod · 0.80
TimestampMethod · 0.80
noErrorFunction · 0.70
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…