aboutsummaryrefslogtreecommitdiff
path: root/rwtransaction_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-02-20 09:24:02 -0700
committerBen Johnson <benbjohnson@yahoo.com>2014-02-20 09:24:02 -0700
commita857b45bac55d1e7954994b72126099c5e44c71f (patch)
tree9f1b78c0e7d23c2f8ef6edfad140f10d98f3eec7 /rwtransaction_test.go
parentMerge branch 'master' of https://github.com/boltdb/bolt (diff)
downloaddedo-a857b45bac55d1e7954994b72126099c5e44c71f.tar.gz
dedo-a857b45bac55d1e7954994b72126099c5e44c71f.tar.xz
Check for sequence overflow.
Diffstat (limited to 'rwtransaction_test.go')
-rw-r--r--rwtransaction_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/rwtransaction_test.go b/rwtransaction_test.go
index ea84b87..18b6ae9 100644
--- a/rwtransaction_test.go
+++ b/rwtransaction_test.go
@@ -136,6 +136,21 @@ func TestRWTransactionNextSequence(t *testing.T) {
})
}
+// Ensure that incrementing past the maximum sequence number will return an error.
+func TestRWTransactionNextSequenceOverflow(t *testing.T) {
+ withOpenDB(func(db *DB, path string) {
+ db.CreateBucket("widgets")
+ db.Do(func(txn *RWTransaction) error {
+ b := txn.Bucket("widgets")
+ b.bucket.sequence = uint64(maxInt)
+ seq, err := txn.NextSequence("widgets")
+ assert.Equal(t, err, ErrSequenceOverflow)
+ assert.Equal(t, seq, 0)
+ return nil
+ })
+ })
+}
+
// Ensure that an error is returned when inserting into a bucket that doesn't exist.
func TestRWTransactionPutBucketNotFound(t *testing.T) {
withOpenDB(func(db *DB, path string) {