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

Function TestMockKV_Put

kv/etcd/mock_test.go:100–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

98}
99
100func TestMockKV_Put(t *testing.T) {
101 t.Run("new key", func(t *testing.T) {
102 kv := newMockKV()
103 _, err := kv.Put(context.Background(), "/foo", "1")
104
105 require.NoError(t, err)
106 assert.Equal(t, int64(1), kv.values["/foo"].Version)
107 assert.Equal(t, []byte("1"), kv.values["/foo"].Value)
108 })
109
110 t.Run("existing key", func(t *testing.T) {
111 kv := newMockKV()
112 kv.values["/foo"] = mvccpb.KeyValue{
113 Key: []byte("/foo"),
114 CreateRevision: 1,
115 ModRevision: 2,
116 Version: 2,
117 Value: []byte("1"),
118 }
119
120 _, err := kv.Put(context.Background(), "/foo", "2")
121
122 require.NoError(t, err)
123 assert.Equal(t, int64(3), kv.values["/foo"].Version)
124 assert.Equal(t, []byte("2"), kv.values["/foo"].Value)
125 })
126}
127
128func TestMockKV_Delete(t *testing.T) {
129 t.Run("exact match", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

newMockKVFunction · 0.85
RunMethod · 0.80
PutMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected