diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-07 12:09:36 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-07 12:09:36 -0600 |
commit | 3d2e092a5deea650f24cfb3d5fb70be7e43b6066 (patch) | |
tree | 3fb231ac0b39c9e45c041fcb9889ae0b11e3741c /bucket_test.go | |
parent | Merge pull request #153 from benbjohnson/consolidate (diff) | |
parent | Minor fixes. (diff) | |
download | dedo-3d2e092a5deea650f24cfb3d5fb70be7e43b6066.tar.gz dedo-3d2e092a5deea650f24cfb3d5fb70be7e43b6066.tar.xz |
Merge pull request #154 from benbjohnson/inline-buckets
(wip) Add inline bucket support.
Diffstat (limited to 'bucket_test.go')
-rw-r--r-- | bucket_test.go | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/bucket_test.go b/bucket_test.go index dc89bcc..b87031b 100644 --- a/bucket_test.go +++ b/bucket_test.go @@ -161,6 +161,33 @@ func TestBucket_Delete(t *testing.T) { }) } +// Ensure that deleting a large set of keys will work correctly. +func TestBucket_Delete_Large(t *testing.T) { + withOpenDB(func(db *DB, path string) { + db.Update(func(tx *Tx) error { + var b, _ = tx.CreateBucket([]byte("widgets")) + for i := 0; i < 100; i++ { + assert.NoError(t, b.Put([]byte(strconv.Itoa(i)), []byte(strings.Repeat("*", 1024)))) + } + return nil + }) + db.Update(func(tx *Tx) error { + var b = tx.Bucket([]byte("widgets")) + for i := 0; i < 100; i++ { + assert.NoError(t, b.Delete([]byte(strconv.Itoa(i)))) + } + return nil + }) + db.View(func(tx *Tx) error { + var b = tx.Bucket([]byte("widgets")) + for i := 0; i < 100; i++ { + assert.Nil(t, b.Get([]byte(strconv.Itoa(i)))) + } + return nil + }) + }) +} + // Ensure that accessing and updating nested buckets is ok across transactions. func TestBucket_Nested(t *testing.T) { withOpenDB(func(db *DB, path string) { @@ -583,18 +610,18 @@ func TestBucket_Stats_Small(t *testing.T) { db.View(func(tx *Tx) error { b := tx.Bucket([]byte("whozawhats")) stats := b.Stats() - assert.Equal(t, stats.BranchPageN, 0) - assert.Equal(t, stats.BranchOverflowN, 0) - assert.Equal(t, stats.LeafPageN, 1) - assert.Equal(t, stats.LeafOverflowN, 0) - assert.Equal(t, stats.KeyN, 1) - assert.Equal(t, stats.Depth, 1) + assert.Equal(t, 0, stats.BranchPageN) + assert.Equal(t, 0, stats.BranchOverflowN) + assert.Equal(t, 1, stats.LeafPageN) + assert.Equal(t, 0, stats.LeafOverflowN) + assert.Equal(t, 1, stats.KeyN) + assert.Equal(t, 1, stats.Depth) if os.Getpagesize() != 4096 { // Incompatible page size - assert.Equal(t, stats.BranchInuse, 0) - assert.Equal(t, stats.BranchAlloc, 0) - assert.Equal(t, stats.LeafInuse, 38) - assert.Equal(t, stats.LeafAlloc, 4096) + assert.Equal(t, 0, stats.BranchInuse) + assert.Equal(t, 0, stats.BranchAlloc) + assert.Equal(t, 38, stats.LeafInuse) + assert.Equal(t, 4096, stats.LeafAlloc) } return nil }) |