MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / TestIterator_KeyValueAfterRelease

Function TestIterator_KeyValueAfterRelease

iterator_test.go:325–355  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

323}
324
325func TestIterator_KeyValueAfterRelease(t *testing.T) {
326 bucket := "bucket"
327
328 runNutsDBTest(t, nil, func(t *testing.T, db *DB) {
329 txCreateBucket(t, db, DataStructureBTree, bucket, nil)
330
331 for i := 0; i < 10; i++ {
332 txPut(t, db, bucket, testutils.GetTestBytes(i), testutils.GetTestBytes(i), Persistent, nil, nil)
333 }
334
335 _ = db.View(func(tx *Tx) error {
336 iterator := NewIterator(tx, bucket, IteratorOptions{Reverse: false})
337
338 // Move to first element
339 require.True(t, iterator.Valid())
340
341 // Release the iterator
342 iterator.Release()
343
344 // After release, should be invalid
345 require.False(t, iterator.Valid())
346 require.Nil(t, iterator.Key())
347 require.Nil(t, iterator.Item())
348
349 _, err := iterator.Value()
350 require.Error(t, err)
351
352 return nil
353 })
354 })
355}
356
357func TestIterator_SeekNonExistent(t *testing.T) {
358 bucket := "bucket"

Callers

nothing calls this directly

Calls 12

ValidMethod · 0.95
ReleaseMethod · 0.95
KeyMethod · 0.95
ItemMethod · 0.95
ValueMethod · 0.95
GetTestBytesFunction · 0.92
runNutsDBTestFunction · 0.85
txCreateBucketFunction · 0.85
txPutFunction · 0.85
NewIteratorFunction · 0.85
ViewMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected