Ensure that a Tx cursor can reverse iterate over an empty bucket without error.
(t *testing.T)
| 386 | |
| 387 | // Ensure that a Tx cursor can reverse iterate over an empty bucket without error. |
| 388 | func TestCursor_EmptyBucketReverse(t *testing.T) { |
| 389 | db := btesting.MustCreateDB(t) |
| 390 | |
| 391 | if err := db.Update(func(tx *bolt.Tx) error { |
| 392 | _, err := tx.CreateBucket([]byte("widgets")) |
| 393 | return err |
| 394 | }); err != nil { |
| 395 | t.Fatal(err) |
| 396 | } |
| 397 | if err := db.View(func(tx *bolt.Tx) error { |
| 398 | c := tx.Bucket([]byte("widgets")).Cursor() |
| 399 | k, v := c.Last() |
| 400 | if k != nil { |
| 401 | t.Fatalf("unexpected key: %v", k) |
| 402 | } else if v != nil { |
| 403 | t.Fatalf("unexpected value: %v", v) |
| 404 | } |
| 405 | return nil |
| 406 | }); err != nil { |
| 407 | t.Fatal(err) |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | // Ensure that a Tx cursor can iterate over a single root with a couple elements. |
| 412 | func TestCursor_Iterate_Leaf(t *testing.T) { |
nothing calls this directly
no test coverage detected