diff options
Diffstat (limited to 'transaction_test.go')
-rw-r--r-- | transaction_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
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) + }) +} |