From a1f43f4d60bf434baebf13b4810e5db4916baec5 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sat, 1 Mar 2014 09:13:59 -0700 Subject: Allow reads of unflushed nodes. This commit allows cursors to read updated values from within the RWTransaction. --- bucket_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'bucket_test.go') diff --git a/bucket_test.go b/bucket_test.go index 5a2c0ae..e4ccabd 100644 --- a/bucket_test.go +++ b/bucket_test.go @@ -23,6 +23,20 @@ func TestBucketGetNonExistent(t *testing.T) { }) } +// Ensure that a bucket can read a value that is not flushed yet. +func TestBucketGetFromNode(t *testing.T) { + withOpenDB(func(db *DB, path string) { + db.CreateBucket("widgets") + db.Do(func(txn *RWTransaction) error { + b := txn.Bucket("widgets") + b.Put([]byte("foo"), []byte("bar")) + value := b.Get([]byte("foo")) + assert.Equal(t, value, []byte("bar")) + return nil + }) + }) +} + // Ensure that a bucket can write a key/value. func TestBucketPut(t *testing.T) { withOpenDB(func(db *DB, path string) { -- cgit v1.2.3