refactor(tests): restore cleanup logic in volume restore tests

This commit is contained in:
Mauricio Siu
2025-12-20 18:50:28 -06:00
parent ed36f37dc9
commit 792bf696a6

View File

@@ -85,37 +85,37 @@ describe(
);
});
// afterEach(async () => {
// console.log(`\n🧹 Cleanup: ${currentVolumeName}`);
// await cleanupDocker(currentVolumeName);
// await cleanupFiles(currentAppName);
afterEach(async () => {
console.log(`\n🧹 Cleanup: ${currentVolumeName}`);
await cleanupDocker(currentVolumeName);
await cleanupFiles(currentAppName);
// // Clean all test volumes
// try {
// const { stdout } = await execAsync(
// `docker volume ls -q --filter "name=test-vol-" || true`,
// );
// if (stdout.trim()) {
// for (const vol of stdout.trim().split("\n")) {
// await execAsync(`docker volume rm ${vol} 2>/dev/null || true`);
// }
// }
// } catch {
// // Ignore
// }
// Clean all test volumes
try {
const { stdout } = await execAsync(
`docker volume ls -q --filter "name=test-vol-" || true`,
);
if (stdout.trim()) {
for (const vol of stdout.trim().split("\n")) {
await execAsync(`docker volume rm ${vol} 2>/dev/null || true`);
}
}
} catch {
// Ignore
}
// // Clean all test backup directories
// try {
// const { VOLUME_BACKUPS_PATH } = paths(false);
// await execAsync(
// `find "${VOLUME_BACKUPS_PATH}" -maxdepth 1 -type d -name "test-*" -exec rm -rf {} + 2>/dev/null || true`,
// );
// } catch {
// // Ignore
// }
// Clean all test backup directories
try {
const { VOLUME_BACKUPS_PATH } = paths(false);
await execAsync(
`find "${VOLUME_BACKUPS_PATH}" -maxdepth 1 -type d -name "test-*" -exec rm -rf {} + 2>/dev/null || true`,
);
} catch {
// Ignore
}
// console.log("✅ Cleanup done\n");
// });
console.log("✅ Cleanup done\n");
});
it(
"should restore volume using real restoreVolume ",