TestDB_Close_ErrorHandling tests error handling during component shutdown
(t *testing.T)
| 1313 | |
| 1314 | // TestDB_Close_ErrorHandling tests error handling during component shutdown |
| 1315 | func TestDB_Close_ErrorHandling(t *testing.T) { |
| 1316 | opts := DefaultOptions |
| 1317 | opts.Dir = filepath.Join(t.TempDir(), "test-close-errors") |
| 1318 | defer func() { _ = os.RemoveAll(opts.Dir) }() |
| 1319 | |
| 1320 | db, err := Open(opts) |
| 1321 | require.NoError(t, err) |
| 1322 | require.NotNil(t, db) |
| 1323 | |
| 1324 | // Close should handle errors gracefully and continue shutting down other components |
| 1325 | err = db.Close() |
| 1326 | require.NoError(t, err) |
| 1327 | |
| 1328 | // Even if there were errors, database should be in closed state |
| 1329 | require.True(t, db.IsClose()) |
| 1330 | require.True(t, db.statusMgr.isClosed()) |
| 1331 | } |
| 1332 | |
| 1333 | func TestDB_ErrThenReadWrite(t *testing.T) { |
| 1334 | runNutsDBTest(t, nil, func(t *testing.T, db *DB) { |