Ensure that a database can be opened without error.
(t *testing.T)
| 48 | |
| 49 | // Ensure that a database can be opened without error. |
| 50 | func 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. |