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

Function OpenDBWithOption

internal/btesting/btesting.go:53–79  ·  view source on GitHub ↗
(t testing.TB, f string, o *bolt.Options)

Source from the content-addressed store, hash-verified

51}
52
53func OpenDBWithOption(t testing.TB, f string, o *bolt.Options) (*DB, error) {
54 t.Logf("Opening bbolt DB at: %s", f)
55 if o == nil {
56 o = bolt.DefaultOptions
57 }
58
59 freelistType := bolt.FreelistArrayType
60 if env := os.Getenv(TestFreelistType); env == string(bolt.FreelistMapType) {
61 freelistType = bolt.FreelistMapType
62 }
63
64 o.FreelistType = freelistType
65
66 db, err := bolt.Open(f, 0600, o)
67 if err != nil {
68 return nil, err
69 }
70 resDB := &DB{
71 DB: db,
72 f: f,
73 o: o,
74 t: t,
75 }
76 resDB.strictModeEnabledDefault()
77 t.Cleanup(resDB.PostTestCleanup)
78 return resDB, nil
79}
80
81func (db *DB) PostTestCleanup() {
82 // Check database consistency after every test.

Calls 1