| 235 | } |
| 236 | |
| 237 | func TestWriteBatch_Data(t *testing.T) { |
| 238 | tempDir := t.TempDir() |
| 239 | cfg := &config.Config{ |
| 240 | LevelDB: config.LevelDBConfig{ |
| 241 | CacheSize: 64 * 1024 * 1024, |
| 242 | BlockSize: 4 * 1024, |
| 243 | WriteBufferSize: 4 * 1024 * 1024, |
| 244 | MaxOpenFiles: 1000, |
| 245 | Compression: true, |
| 246 | }, |
| 247 | } |
| 248 | |
| 249 | db, err := Store{}.Open(tempDir, cfg) |
| 250 | require.NoError(t, err) |
| 251 | defer db.Close() |
| 252 | |
| 253 | wb := db.NewWriteBatch() |
| 254 | defer wb.Close() |
| 255 | |
| 256 | // Add operations |
| 257 | wb.Put([]byte("key1"), []byte("value1")) |
| 258 | wb.Delete([]byte("key2")) |
| 259 | wb.Put([]byte("key3"), []byte("value3")) |
| 260 | |
| 261 | // Get batch data |
| 262 | data := wb.Data() |
| 263 | assert.NotNil(t, data) |
| 264 | assert.Greater(t, len(data), 0) |
| 265 | |
| 266 | // Commit should still work |
| 267 | err = wb.Commit() |
| 268 | require.NoError(t, err) |
| 269 | } |
| 270 | |
| 271 | func TestWriteBatch_Concurrent(t *testing.T) { |
| 272 | tempDir := t.TempDir() |