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

Function TestBucket_Delete_NonExisting

bucket_test.go:439–468  ·  view source on GitHub ↗

Ensure that deleting of non-existing key is a no-op.

(t *testing.T)

Source from the content-addressed store, hash-verified

437
438// Ensure that deleting of non-existing key is a no-op.
439func TestBucket_Delete_NonExisting(t *testing.T) {
440 db := btesting.MustCreateDB(t)
441
442 if err := db.Update(func(tx *bolt.Tx) error {
443 b, err := tx.CreateBucket([]byte("widgets"))
444 if err != nil {
445 t.Fatal(err)
446 }
447
448 if _, err = b.CreateBucket([]byte("nested")); err != nil {
449 t.Fatal(err)
450 }
451 return nil
452 }); err != nil {
453 t.Fatal(err)
454 }
455
456 if err := db.Update(func(tx *bolt.Tx) error {
457 b := tx.Bucket([]byte("widgets"))
458 if err := b.Delete([]byte("foo")); err != nil {
459 t.Fatal(err)
460 }
461 if b.Bucket([]byte("nested")) == nil {
462 t.Fatal("nested bucket has been deleted")
463 }
464 return nil
465 }); err != nil {
466 t.Fatal(err)
467 }
468}
469
470// Ensure that accessing and updating nested buckets is ok across transactions.
471func TestBucket_Nested(t *testing.T) {

Callers

nothing calls this directly

Calls 6

MustCreateDBFunction · 0.92
UpdateMethod · 0.80
FatalMethod · 0.65
CreateBucketMethod · 0.45
BucketMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…