MCPcopy
hub / github.com/etcd-io/bbolt / TestOpen_Check

Function TestOpen_Check

db_test.go:397–422  ·  view source on GitHub ↗

Ensure that a re-opened database is consistent.

(t *testing.T)

Source from the content-addressed store, hash-verified

395
396// Ensure that a re-opened database is consistent.
397func TestOpen_Check(t *testing.T) {
398 path := tempfile()
399 defer os.RemoveAll(path)
400
401 db, err := bolt.Open(path, 0600, nil)
402 if err != nil {
403 t.Fatal(err)
404 }
405 if err = db.View(func(tx *bolt.Tx) error { return <-tx.Check() }); err != nil {
406 t.Fatal(err)
407 }
408 if err = db.Close(); err != nil {
409 t.Fatal(err)
410 }
411
412 db, err = bolt.Open(path, 0600, nil)
413 if err != nil {
414 t.Fatal(err)
415 }
416 if err := db.View(func(tx *bolt.Tx) error { return <-tx.Check() }); err != nil {
417 t.Fatal(err)
418 }
419 if err := db.Close(); err != nil {
420 t.Fatal(err)
421 }
422}
423
424// Ensure that write errors to the meta file handler during initialization are returned.
425func TestOpen_MetaInitWriteError(t *testing.T) {

Callers

nothing calls this directly

Calls 5

tempfileFunction · 0.85
ViewMethod · 0.80
CheckMethod · 0.80
FatalMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected