MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestFlyDbStore_Set

Function TestFlyDbStore_Set

lib/datastore/flydb_test.go:169–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func TestFlyDbStore_Set(t *testing.T) {
170 ds, err := testFlyDbDatastore()
171 assert.NoError(t, err)
172 type kv struct {
173 key string
174 val string
175 }
176 type test struct {
177 input []kv
178 expectError bool
179 }
180 tests := []test{
181 {
182 input: []kv{
183 {key: "1", val: "2"},
184 {key: "foo", val: "bar"},
185 {key: "hello", val: "world"},
186 },
187 expectError: false,
188 },
189 {
190 input: []kv{
191 {key: "", val: "bar"},
192 },
193 expectError: true,
194 },
195 }
196 for _, tc := range tests {
197 // set all inputs
198 for _, v := range tc.input {
199 err := ds.Set(stringToBytes(v.key), stringToBytes(v.val))
200 if tc.expectError {
201 assert.NotNil(t, err)
202 } else {
203 assert.NoError(t, err)
204 }
205 }
206 // recall all inputs
207 for _, v := range tc.input {
208 val, err := ds.Get(stringToBytes(v.key))
209 if tc.expectError {
210 assert.NotNil(t, err)
211 } else {
212 assert.NoError(t, err)
213 assert.Equal(t, v.val, string(val))
214 }
215 }
216
217 }
218
219}
220func TestFlyDbStore_Get(t *testing.T) {
221 type kv struct {
222 key string

Callers

nothing calls this directly

Calls 4

testFlyDbDatastoreFunction · 0.85
stringToBytesFunction · 0.85
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected