refactor(tests): improve volume backup test command handling and add error check for backup file

This commit is contained in:
Mauricio Siu
2025-12-20 18:59:14 -06:00
parent 792bf696a6
commit ff0b8ffdb7

View File

@@ -46,10 +46,7 @@ const createMockDestination = () => ({
endpoint: "s3.amazonaws.com",
});
const createMockVolumeBackup = (
volumeName: string,
appName: string,
): Partial<VolumeBackupData> => ({
const createMockVolumeBackup = (volumeName: string, appName: string): any => ({
volumeBackupId: "id",
name: "Test",
volumeName,
@@ -241,10 +238,11 @@ describe(
// Extract and execute just the backup part of the command (tar creation)
// This is what Dokploy really does
const commandWithoutS3 = fullCommand.replace(
/rclone copyto[^\n]+/g,
'echo "Skipping S3 upload - keeping file locally for test"',
);
const commandWithoutS3 =
fullCommand?.replace(
/rclone copyto[^\n]+/g,
'echo "Skipping S3 upload - keeping file locally for test"',
) || "";
// Also prevent the cleanup of the backup file so we can verify it
const commandWithoutCleanup = commandWithoutS3.replace(
@@ -274,6 +272,10 @@ describe(
);
const backupFilePath = backupFiles.trim().split("\n")[0];
if (!backupFilePath) {
throw new Error("No backup file found");
}
expect(existsSync(backupFilePath)).toBe(true);
console.log(`✅ Backup file created: ${path.basename(backupFilePath)}`);