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

Function TestDB_Fold

engine/db_test.go:367–392  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

365}
366
367func TestDB_Fold(t *testing.T) {
368 opts := config.DefaultOptions
369 dir, _ := os.MkdirTemp("", "flydb-fold")
370 opts.DirPath = dir
371 opts.DataFileSize = 64 * 1024 * 1024
372 db, err := NewDB(opts)
373 defer destroyDB(db)
374 assert.Nil(t, err)
375 assert.NotNil(t, db)
376
377 err = db.Put(randkv.GetTestKey(10), randkv.RandomValue(20))
378 assert.Nil(t, err)
379 err = db.Put(randkv.GetTestKey(20), randkv.RandomValue(20))
380 assert.Nil(t, err)
381 err = db.Put(randkv.GetTestKey(30), randkv.RandomValue(20))
382 assert.Nil(t, err)
383 err = db.Put(randkv.GetTestKey(40), randkv.RandomValue(20))
384 assert.Nil(t, err)
385
386 err = db.Fold(func(key []byte, value []byte) bool {
387 assert.NotNil(t, key)
388 assert.NotNil(t, value)
389 return true
390 })
391 assert.Nil(t, err)
392}
393
394func TestDB_Close(t *testing.T) {
395 opts := config.DefaultOptions

Callers

nothing calls this directly

Calls 6

PutMethod · 0.95
FoldMethod · 0.95
GetTestKeyFunction · 0.92
RandomValueFunction · 0.92
NewDBFunction · 0.85
destroyDBFunction · 0.85

Tested by

no test coverage detected