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

Function TestFlyDbStore_GetUint64

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

Source from the content-addressed store, hash-verified

328
329}
330func TestFlyDbStore_GetUint64(t *testing.T) {
331 type kv struct {
332 key string
333 val uint64
334 }
335 type test struct {
336 name string
337 input []kv
338 query []kv
339 expectError bool
340 }
341 tests := []test{
342 {
343 name: "set three",
344 input: []kv{
345 {key: "1", val: 11},
346 {key: "foo", val: 55},
347 {key: "hello", val: 336},
348 },
349 query: []kv{
350 {key: "1", val: 11},
351 {key: "foo", val: 55},
352 {key: "hello", val: 336},
353 },
354 expectError: false,
355 },
356 {
357 name: "non existence",
358 input: []kv{
359 {key: "4", val: 2},
360 },
361 query: []kv{
362 {key: "1", val: 2},
363 {key: "2", val: 4},
364 },
365 expectError: true,
366 },
367 }
368 for _, tc := range tests {
369 ds, err := testFlyDbDatastore()
370 assert.NoError(t, err)
371 // set all inputs
372 for _, v := range tc.input {
373 _ = ds.Set(stringToBytes(v.key), uint64ToBytes(v.val))
374
375 }
376 // recall all inputs
377 for _, v := range tc.query {
378 val, err := ds.Get(stringToBytes(v.key))
379 if tc.expectError {
380 assert.NotNil(t, err)
381 } else {
382 assert.NoError(t, err)
383 assert.Equal(t, v.val, bytesToUint64(val))
384 }
385 }
386
387 }

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