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

Function TestCursor_EmptyBucketReverse

cursor_test.go:388–409  ·  view source on GitHub ↗

Ensure that a Tx cursor can reverse iterate over an empty bucket without error.

(t *testing.T)

Source from the content-addressed store, hash-verified

386
387// Ensure that a Tx cursor can reverse iterate over an empty bucket without error.
388func 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.
412func TestCursor_Iterate_Leaf(t *testing.T) {

Callers

nothing calls this directly

Calls 9

MustCreateDBFunction · 0.92
UpdateMethod · 0.80
ViewMethod · 0.80
LastMethod · 0.80
FatalMethod · 0.65
FatalfMethod · 0.65
CreateBucketMethod · 0.45
CursorMethod · 0.45
BucketMethod · 0.45

Tested by

no test coverage detected