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

Function TestOpen

db_test.go:50–68  ·  view source on GitHub ↗

Ensure that a database can be opened without error.

(t *testing.T)

Source from the content-addressed store, hash-verified

48
49// Ensure that a database can be opened without error.
50func TestOpen(t *testing.T) {
51 path := tempfile()
52 defer os.RemoveAll(path)
53
54 db, err := bolt.Open(path, 0600, nil)
55 if err != nil {
56 t.Fatal(err)
57 } else if db == nil {
58 t.Fatal("expected db")
59 }
60
61 if s := db.Path(); s != path {
62 t.Fatalf("unexpected path: %s", s)
63 }
64
65 if err := db.Close(); err != nil {
66 t.Fatal(err)
67 }
68}
69
70// Regression validation for https://github.com/etcd-io/bbolt/pull/122.
71// Tests multiple goroutines simultaneously opening a database.

Callers

nothing calls this directly

Calls 5

tempfileFunction · 0.85
FatalMethod · 0.65
FatalfMethod · 0.65
PathMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected