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

Function TestFlyDbStore_SetUint64

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

Source from the content-addressed store, hash-verified

278
279}
280func TestFlyDbStore_SetUint64(t *testing.T) {
281 ds, err := testFlyDbDatastore()
282 assert.NoError(t, err)
283 type kv struct {
284 key string
285 val uint64
286 }
287 type test struct {
288 input []kv
289 expectError bool
290 }
291 tests := []test{
292 {
293 input: []kv{
294 {key: "1", val: 2343},
295 {key: "foo", val: 23},
296 {key: "hello", val: 5645},
297 },
298 expectError: false,
299 },
300 {
301 input: []kv{
302 {key: "", val: 654},
303 },
304 expectError: true,
305 },
306 }
307 for _, tc := range tests {
308 // set all inputs
309 for _, v := range tc.input {
310 err := ds.Set(stringToBytes(v.key), uint64ToBytes(v.val))
311 if tc.expectError {
312 assert.NotNil(t, err)
313 } else {
314 assert.NoError(t, err)
315 }
316 }
317 // recall all inputs
318 for _, v := range tc.input {
319 val, err := ds.Get(stringToBytes(v.key))
320 if tc.expectError {
321 assert.NotNil(t, err)
322 } else {
323 assert.NoError(t, err)
324 assert.Equal(t, v.val, bytesToUint64(val))
325 }
326 }
327 }
328
329}
330func TestFlyDbStore_GetUint64(t *testing.T) {
331 type kv struct {
332 key string

Callers

nothing calls this directly

Calls 6

testFlyDbDatastoreFunction · 0.85
stringToBytesFunction · 0.85
uint64ToBytesFunction · 0.85
bytesToUint64Function · 0.85
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected