MCPcopy
hub / github.com/etcd-io/bbolt / TestBucket_Delete

Function TestBucket_Delete

bucket_test.go:306–327  ·  view source on GitHub ↗

Ensure that a bucket can delete an existing key.

(t *testing.T)

Source from the content-addressed store, hash-verified

304
305// Ensure that a bucket can delete an existing key.
306func TestBucket_Delete(t *testing.T) {
307 db := btesting.MustCreateDB(t)
308
309 if err := db.Update(func(tx *bolt.Tx) error {
310 b, err := tx.CreateBucket([]byte("widgets"))
311 if err != nil {
312 t.Fatal(err)
313 }
314 if err := b.Put([]byte("foo"), []byte("bar")); err != nil {
315 t.Fatal(err)
316 }
317 if err := b.Delete([]byte("foo")); err != nil {
318 t.Fatal(err)
319 }
320 if v := b.Get([]byte("foo")); v != nil {
321 t.Fatalf("unexpected value: %v", v)
322 }
323 return nil
324 }); err != nil {
325 t.Fatal(err)
326 }
327}
328
329// Ensure that deleting a large set of keys will work correctly.
330func TestBucket_Delete_Large(t *testing.T) {

Callers

nothing calls this directly

Calls 8

MustCreateDBFunction · 0.92
UpdateMethod · 0.80
FatalMethod · 0.65
FatalfMethod · 0.65
CreateBucketMethod · 0.45
PutMethod · 0.45
DeleteMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected