MCPcopy
hub / github.com/dgraph-io/badger / TestLargeKeys

Function TestLargeKeys

db_test.go:1350–1389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1348}
1349
1350func TestLargeKeys(t *testing.T) {
1351 test := func(t *testing.T, opt Options) {
1352 db, err := Open(opt)
1353 require.NoError(t, err)
1354 for i := 0; i < 1000; i++ {
1355 tx := db.NewTransaction(true)
1356 for _, kv := range benchmarkData {
1357 k := make([]byte, len(kv.key))
1358 copy(k, kv.key)
1359
1360 v := make([]byte, len(kv.value))
1361 copy(v, kv.value)
1362 if err := tx.SetEntry(NewEntry(k, v)); err != nil {
1363 // check is success should be true
1364 if kv.success {
1365 t.Fatalf("failed with: %s", err)
1366 }
1367 } else if !kv.success {
1368 t.Fatal("insertion should fail")
1369 }
1370 }
1371 if err := tx.Commit(); err != nil {
1372 t.Fatalf("#%d: batchSet err: %v", i, err)
1373 }
1374 }
1375 require.NoError(t, db.Close())
1376 }
1377 t.Run("disk mode", func(t *testing.T) {
1378 dir, err := ioutil.TempDir("", "badger-test")
1379 require.NoError(t, err)
1380 defer removeDir(dir)
1381 opt := DefaultOptions(dir).WithValueLogFileSize(1024 * 1024 * 1024)
1382 test(t, opt)
1383 })
1384 t.Run("InMemory mode", func(t *testing.T) {
1385 opt := DefaultOptions("").WithValueLogFileSize(1024 * 1024 * 1024)
1386 opt.InMemory = true
1387 test(t, opt)
1388 })
1389}
1390
1391func TestCreateDirs(t *testing.T) {
1392 dir, err := ioutil.TempDir("", "parent")

Callers

nothing calls this directly

Calls 9

OpenFunction · 0.85
NewEntryFunction · 0.85
removeDirFunction · 0.85
DefaultOptionsFunction · 0.85
NewTransactionMethod · 0.80
CommitMethod · 0.80
WithValueLogFileSizeMethod · 0.80
CloseMethod · 0.65
SetEntryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…