aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-02-03 14:33:51 -0700
committerBen Johnson <benbjohnson@yahoo.com>2014-02-03 14:33:51 -0700
commit0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8 (patch)
tree96120044d92bcfbcbf5258bdf9c334448fc55aa7 /db_test.go
parentMerge pull request #5 from benbjohnson/put (diff)
downloaddedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.gz
dedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.xz
Add RWTransaction.Delete().
Diffstat (limited to 'db_test.go')
-rw-r--r--db_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/db_test.go b/db_test.go
index 50ec3c3..224cfc7 100644
--- a/db_test.go
+++ b/db_test.go
@@ -191,6 +191,20 @@ func TestDBPutRandom(t *testing.T) {
}
}
+// Ensure that a bucket can delete an existing key.
+func TestDBDelete(t *testing.T) {
+ withOpenDB(func(db *DB, path string) {
+ db.CreateBucket("widgets")
+ db.Put("widgets", []byte("foo"), []byte("bar"))
+ err := db.Delete("widgets", []byte("foo"))
+ assert.NoError(t, err)
+ value, err := db.Get("widgets", []byte("foo"))
+ if assert.NoError(t, err) {
+ assert.Nil(t, value)
+ }
+ })
+}
+
// withDB executes a function with a database reference.
func withDB(fn func(*DB, string)) {
f, _ := ioutil.TempFile("", "bolt-")