MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestIterator_Close

Function TestIterator_Close

driver/hybriddb/iterator_test.go:121–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestIterator_Close(t *testing.T) {
122 tempDir := t.TempDir()
123 cfg := &config.Config{
124 LevelDB: config.LevelDBConfig{
125 CacheSize: 64 * 1024 * 1024,
126 BlockSize: 4 * 1024,
127 WriteBufferSize: 4 * 1024 * 1024,
128 MaxOpenFiles: 1000,
129 Compression: true,
130 },
131 }
132
133 db, err := Store{}.Open(tempDir, cfg)
134 require.NoError(t, err)
135 defer db.Close()
136
137 iter := db.NewIterator()
138
139 // Should be able to use iterator before closing
140 iter.First()
141 assert.False(t, iter.Valid()) // Empty DB
142
143 // Close should work without errors
144 err = iter.Close()
145 assert.NoError(t, err)
146
147 // Double close should not panic
148 err = iter.Close()
149 assert.NoError(t, err)
150}

Callers

nothing calls this directly

Calls 6

FirstMethod · 0.95
ValidMethod · 0.95
CloseMethod · 0.95
CloseMethod · 0.65
OpenMethod · 0.45
NewIteratorMethod · 0.45

Tested by

no test coverage detected