MCPcopy
hub / github.com/grafana/dskit / TestMemcachedClient_Add

Function TestMemcachedClient_Add

cache/memcached_client_test.go:85–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func TestMemcachedClient_Add(t *testing.T) {
86 t.Run("item does not exist", func(t *testing.T) {
87 ctx := context.Background()
88 client, _, err := setupDefaultMemcachedClient()
89 require.NoError(t, err)
90 require.NoError(t, client.Add(ctx, "foo", []byte("bar"), time.Minute))
91 })
92
93 t.Run("item already exists", func(t *testing.T) {
94 ctx := context.Background()
95 client, mock, err := setupDefaultMemcachedClient()
96 require.NoError(t, err)
97
98 require.NoError(t, mock.Set(&memcache.Item{
99 Key: "foo",
100 Value: []byte("baz"),
101 Expiration: 60,
102 }))
103
104 err = client.Add(ctx, "foo", []byte("bar"), time.Minute)
105 require.ErrorIs(t, err, ErrNotStored)
106 })
107}
108
109func TestMemcachedClient_GetMulti(t *testing.T) {
110 t.Run("no allocator", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

RunMethod · 0.80
AddMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected