diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-04 15:30:05 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-05 07:56:13 -0700 |
commit | 8b3b81ef47d8eaa1f95e152943fd10b03b782034 (patch) | |
tree | b4facd8b21cba315de943c7946c67f685ee4900a /transaction_test.go | |
parent | Add RWTransaction.Delete(). (diff) | |
download | dedo-8b3b81ef47d8eaa1f95e152943fd10b03b782034.tar.gz dedo-8b3b81ef47d8eaa1f95e152943fd10b03b782034.tar.xz |
Fix quick tests.
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) + }) +} |