MCPcopy Index your code
hub / github.com/upper/db / TestCache

Function TestCache

internal/cache/cache_test.go:42–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestCache(t *testing.T) {
43 var c *Cache
44
45 var (
46 key = cacheableT{"foo"}
47 value = "bar"
48 )
49
50 t.Run("New", func(t *testing.T) {
51 c = NewCache()
52 assert.NotNil(t, c)
53 })
54
55 t.Run("ReadNonExistentValue", func(t *testing.T) {
56 _, ok := c.Read(&key)
57 assert.False(t, ok)
58 })
59
60 t.Run("Write", func(t *testing.T) {
61 c.Write(&key, value)
62 c.Write(&key, value)
63 })
64
65 t.Run("ReadExistentValue", func(t *testing.T) {
66 v, ok := c.Read(&key)
67 assert.True(t, ok)
68 assert.Equal(t, value, v)
69 })
70}
71
72func BenchmarkNewCache(b *testing.B) {
73 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 3

ReadMethod · 0.95
WriteMethod · 0.95
NewCacheFunction · 0.85

Tested by

no test coverage detected