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

Function TestBoltDbStore_SetUint64

lib/datastore/boltdb_test.go:279–328  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected