aboutsummaryrefslogtreecommitdiff
path: root/tx_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tx_test.go')
-rw-r--r--tx_test.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/tx_test.go b/tx_test.go
index 1274476..abdd6d4 100644
--- a/tx_test.go
+++ b/tx_test.go
@@ -190,12 +190,27 @@ func TestTxDeleteBucketNotFound(t *testing.T) {
func TestTxCursorEmptyBucket(t *testing.T) {
withOpenDB(func(db *DB, path string) {
db.CreateBucket("widgets")
- tx, _ := db.Tx()
- c := tx.Bucket("widgets").Cursor()
- k, v := c.First()
- assert.Nil(t, k)
- assert.Nil(t, v)
- tx.Commit()
+ db.With(func(tx *Tx) error {
+ c := tx.Bucket("widgets").Cursor()
+ k, v := c.First()
+ assert.Nil(t, k)
+ assert.Nil(t, v)
+ return nil
+ })
+ })
+}
+
+// Ensure that a Tx cursor can reverse iterate over an empty bucket without error.
+func TestCursorEmptyBucketReverse(t *testing.T) {
+ withOpenDB(func(db *DB, path string) {
+ db.CreateBucket("widgets")
+ db.With(func(tx *Tx) error {
+ c := tx.Bucket("widgets").Cursor()
+ k, v := c.Last()
+ assert.Nil(t, k)
+ assert.Nil(t, v)
+ return nil
+ })
})
}