mirror of https://github.com/etcd-io/bbolt.git
31 lines
659 B
Go
31 lines
659 B
Go
package bolt
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// Ensure that a RWTransaction can be retrieved.
|
|
func TestRWTransaction(t *testing.T) {
|
|
withOpenDB(func(db *DB, path string) {
|
|
txn, err := db.RWTransaction()
|
|
assert.NotNil(t, txn)
|
|
assert.NoError(t, err)
|
|
})
|
|
}
|
|
|
|
// Ensure that a bucket can be created and retrieved.
|
|
func TestTransactionCreateBucket(t *testing.T) {
|
|
withOpenDB(func(db *DB, path string) {
|
|
// Create a bucket.
|
|
err := db.CreateBucket("widgets")
|
|
assert.NoError(t, err)
|
|
|
|
// Read the bucket through a separate transaction.
|
|
b, err := db.Bucket("widgets")
|
|
assert.NotNil(t, b)
|
|
assert.NoError(t, err)
|
|
})
|
|
}
|