diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-05 21:50:15 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-05 21:50:15 -0700 |
commit | 4820312de29f446152fce216c17a696576e89d78 (patch) | |
tree | 31e748c7f977071af779aaa42a80ff728b495da6 /transaction_test.go | |
parent | Add pre-alpha badge. (diff) | |
parent | Fix quick tests. (diff) | |
download | dedo-4820312de29f446152fce216c17a696576e89d78.tar.gz dedo-4820312de29f446152fce216c17a696576e89d78.tar.xz |
Merge pull request #7 from benbjohnson/delete
RWTransaction.Delete()
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) + }) +} |