From 8b3b81ef47d8eaa1f95e152943fd10b03b782034 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 4 Feb 2014 15:30:05 -0700 Subject: Fix quick tests. --- transaction_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 transaction_test.go (limited to 'transaction_test.go') diff --git a/transaction_test.go b/transaction_test.go new file mode 100644 index 0000000..55e8bde --- /dev/null +++ b/transaction_test.go @@ -0,0 +1,30 @@ +package bolt + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// Ensure that a Transaction can retrieve a bucket. +func TestTransactionBucketMissing(t *testing.T) { + withOpenDB(func(db *DB, path string) { + db.CreateBucket("widgets") + b, err := db.Bucket("widgets") + assert.NoError(t, err) + if assert.NotNil(t, b) { + assert.Equal(t, "widgets", b.Name()) + } + }) +} + +// Ensure that a Transaction retrieving a non-existent key returns nil. +func TestTransactionGetMising(t *testing.T) { + withOpenDB(func(db *DB, path string) { + db.CreateBucket("widgets") + db.Put("widgets", []byte("foo"), []byte("bar")) + value, err := db.Get("widgets", []byte("no_such_key")) + assert.NoError(t, err) + assert.Nil(t, value) + }) +} -- cgit v1.2.3