Ensure that a bucket can delete an existing key.
(t *testing.T)
| 304 | |
| 305 | // Ensure that a bucket can delete an existing key. |
| 306 | func 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. |
| 330 | func TestBucket_Delete_Large(t *testing.T) { |
nothing calls this directly
no test coverage detected