diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-03 14:33:51 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-03 14:33:51 -0700 |
commit | 0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8 (patch) | |
tree | 96120044d92bcfbcbf5258bdf9c334448fc55aa7 /db_test.go | |
parent | Merge pull request #5 from benbjohnson/put (diff) | |
download | dedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.gz dedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.xz |
Add RWTransaction.Delete().
Diffstat (limited to 'db_test.go')
-rw-r--r-- | db_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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-") |