diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-27 11:55:44 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-27 11:55:44 -0700 |
commit | 9abced434f459c20fd6629efa2be0b91e56de179 (patch) | |
tree | 050d00d7faca649cd0ce7ea7851e3781bd7b1d15 /rwtransaction_test.go | |
parent | Merge pull request #53 from benbjohnson/open-api (diff) | |
download | dedo-9abced434f459c20fd6629efa2be0b91e56de179.tar.gz dedo-9abced434f459c20fd6629efa2be0b91e56de179.tar.xz |
Add bucket reclamation.
After RWTransaction.DeleteBucket() is called, all pages related to the
bucket are moved to the freelist for that transaction.
Diffstat (limited to 'rwtransaction_test.go')
-rw-r--r-- | rwtransaction_test.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/rwtransaction_test.go b/rwtransaction_test.go index 83b2d1f..1635b45 100644 --- a/rwtransaction_test.go +++ b/rwtransaction_test.go @@ -66,6 +66,7 @@ func TestRWTransactionCreateBucketIfNotExists(t *testing.T) { withOpenDB(func(db *DB, path string) { assert.NoError(t, db.CreateBucketIfNotExists("widgets")) assert.NoError(t, db.CreateBucketIfNotExists("widgets")) + assert.Equal(t, db.CreateBucketIfNotExists(""), ErrBucketNameRequired) // Read the bucket through a separate transaction. b, err := db.Bucket("widgets") @@ -113,12 +114,17 @@ func TestRWTransactionDeleteBucket(t *testing.T) { db.CreateBucket("widgets") db.Put("widgets", []byte("foo"), []byte("bar")) + b, _ := db.Bucket("widgets") + // Delete the bucket and make sure we can't get the value. assert.NoError(t, db.DeleteBucket("widgets")) value, err := db.Get("widgets", []byte("foo")) assert.Equal(t, err, ErrBucketNotFound) assert.Nil(t, value) + // Verify that the bucket's page is free. + assert.Equal(t, db.freelist.all(), []pgid{b.root}) + // Create the bucket again and make sure there's not a phantom value. assert.NoError(t, db.CreateBucket("widgets")) value, err = db.Get("widgets", []byte("foo")) |