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

Function TestCursor_RepeatOperations

cursor_test.go:25–59  ·  cursor_test.go::TestCursor_RepeatOperations

TestCursor_RepeatOperations verifies that a cursor can continue to iterate over all elements in reverse direction when it has already reached to the end or beginning. Refer to https://github.com/etcd-io/bbolt/issues/733

(t *testing.T)

Source from the content-addressed store, hash-verified

23// reached to the end or beginning.
24// Refer to https://github.com/etcd-io/bbolt/issues/733
25func TestCursor_RepeatOperations(t *testing.T) {
26 testCases := []struct {
27 name string
28 testFunc func(t2 *testing.T, bucket *bolt.Bucket)
29 }{
30 {
31 name: "Repeat NextPrevNext",
32 testFunc: testRepeatCursorOperations_NextPrevNext,
33 },
34 {
35 name: "Repeat PrevNextPrev",
36 testFunc: testRepeatCursorOperations_PrevNextPrev,
37 },
38 }
39
40 for _, tc := range testCases {
41 t.Run(tc.name, func(t *testing.T) {
42 db := btesting.MustCreateDBWithOption(t, &bolt.Options{PageSize: 4096})
43
44 bucketName := []byte("data")
45
46 _ = db.Update(func(tx *bolt.Tx) error {
47 b, _ := tx.CreateBucketIfNotExists(bucketName)
48 testCursorRepeatOperations_PrepareData(t, b)
49 return nil
50 })
51
52 _ = db.View(func(tx *bolt.Tx) error {
53 b := tx.Bucket(bucketName)
54 tc.testFunc(t, b)
55 return nil
56 })
57 })
58 }
59}
60
61func testCursorRepeatOperations_PrepareData(t *testing.T, b *bolt.Bucket) {
62 // ensure we have at least one branch page.

Callers

nothing calls this directly

Calls 7

MustCreateDBWithOptionFunction · 0.92
RunMethod · 0.80
UpdateMethod · 0.80
ViewMethod · 0.80
BucketMethod · 0.45

Tested by

no test coverage detected