Skip to content

Commit 27b605f

Browse files
author
Mauricio Siu
committed
refactor: update comments and improve clarity in application real tests
- Translated comments from Spanish to English for better accessibility. - Enhanced comment clarity to improve understanding of test behavior and expectations.
1 parent a72281c commit 27b605f

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

apps/dokploy/__test__/deploy/application.real.test.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { execAsync } from "@dokploy/server/utils/process/execAsync";
66
import { format } from "date-fns";
77
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
88

9-
const REAL_TEST_TIMEOUT = 180000; // 3 minutos
9+
const REAL_TEST_TIMEOUT = 180000; // 3 minutes
1010

11-
// Mock SOLO la base de datos y notificaciones
11+
// Mock ONLY database and notifications
1212
vi.mock("@dokploy/server/db", () => {
1313
const createChainableMock = (): any => {
1414
const chain: any = {
@@ -67,11 +67,11 @@ vi.mock("@dokploy/server/services/rollbacks", () => ({
6767
createRollback: vi.fn(),
6868
}));
6969

70-
// NO mockeamos:
71-
// - execAsync (queremos que se ejecute de verdad)
72-
// - cloneGitRepository (queremos que se ejecute de verdad)
73-
// - getBuildCommand (queremos que se ejecute de verdad)
74-
// - mechanizeDockerContainer (queremos que se ejecute de verdad)
70+
// NOT mocked (executed for real):
71+
// - execAsync
72+
// - cloneGitRepository
73+
// - getBuildCommand
74+
// - mechanizeDockerContainer (requires Docker Swarm)
7575

7676
import { db } from "@dokploy/server/db";
7777
import * as adminService from "@dokploy/server/services/admin";
@@ -122,7 +122,7 @@ const createMockDeployment = async (appName: string) => {
122122
const fileName = `${appName}-${formattedDateTime}.log`;
123123
const logFilePath = path.join(LOGS_PATH, appName, fileName);
124124

125-
// Crear el directorio de logs REALMENTE
125+
// Actually create the log directory
126126
await execAsync(`mkdir -p ${path.dirname(logFilePath)}`);
127127
await execAsync(`echo "Initializing deployment" > ${logFilePath}`);
128128

@@ -146,11 +146,11 @@ async function cleanupFiles(appName: string) {
146146
try {
147147
const { LOGS_PATH, APPLICATIONS_PATH } = paths(false);
148148

149-
// Limpiar directorios de código clonado
149+
// Clean cloned code directories
150150
const appPath = path.join(APPLICATIONS_PATH, appName);
151151
await execAsync(`rm -rf ${appPath} 2>/dev/null || true`);
152152

153-
// Limpiar logs del appName - elimina el folder completo
153+
// Clean logs for appName - removes entire folder
154154
const logPath = path.join(LOGS_PATH, appName);
155155
await execAsync(`rm -rf ${logPath} 2>/dev/null || true`);
156156

@@ -199,18 +199,18 @@ describe(
199199
});
200200

201201
afterEach(async () => {
202-
// SIEMPRE limpia, incluso si el test falló o pasó
202+
// ALWAYS cleanup, even if test failed or passed
203203
console.log(`\n🧹 Cleaning up test: ${currentAppName}`);
204204

205-
// Limpiar el appName actual
205+
// Clean current appName
206206
try {
207207
await cleanupDocker(currentAppName);
208208
await cleanupFiles(currentAppName);
209209
} catch (error) {
210210
console.error("⚠️ Error cleaning current app:", error);
211211
}
212212

213-
// Limpiar TODOS los folders de test por si acaso
213+
// Clean ALL test folders just in case
214214
try {
215215
const { LOGS_PATH, APPLICATIONS_PATH } = paths(false);
216216
await execAsync(`rm -rf ${LOGS_PATH}/real-* 2>/dev/null || true`);
@@ -238,15 +238,15 @@ describe(
238238

239239
expect(result).toBe(true);
240240

241-
// Verificar que la imagen Docker fue creada DE VERDAD
241+
// Verify that Docker image was actually created
242242
const { stdout: dockerImages } = await execAsync(
243243
`docker images ${currentAppName} --format "{{.Repository}}"`,
244244
);
245245
console.log("dockerImages", dockerImages);
246246
expect(dockerImages.trim()).toBe(currentAppName);
247247
console.log(`✅ Docker image created: ${currentAppName}`);
248248

249-
// Verificar que el log existe y tiene contenido
249+
// Verify log exists and has content
250250
expect(existsSync(currentDeployment.logPath)).toBe(true);
251251
const { stdout: logContent } = await execAsync(
252252
`cat ${currentDeployment.logPath}`,
@@ -255,7 +255,7 @@ describe(
255255
expect(logContent).toContain("nixpacks");
256256
console.log(`✅ Build log created with ${logContent.length} chars`);
257257

258-
// Verificar que las funciones de actualización fueron llamadas
258+
// Verify update functions were called
259259
expect(deploymentService.updateDeploymentStatus).toHaveBeenCalledWith(
260260
"deployment-id",
261261
"done",
@@ -337,13 +337,13 @@ describe(
337337
}),
338338
).rejects.toThrow();
339339

340-
// Verificar que se llamó con estado de error
340+
// Verify error status was called
341341
expect(deploymentService.updateDeploymentStatus).toHaveBeenCalledWith(
342342
"deployment-id",
343343
"error",
344344
);
345345

346-
// Verificar que el log contiene el error
346+
// Verify log contains error
347347
const { stdout: logContent } = await execAsync(
348348
`cat ${currentDeployment.logPath}`,
349349
);
@@ -381,15 +381,15 @@ describe(
381381

382382
expect(result).toBe(true);
383383

384-
// Verificar que el deployment completó exitosamente
384+
// Verify deployment completed successfully
385385
const { stdout: logContent } = await execAsync(
386386
`cat ${currentDeployment.logPath}`,
387387
);
388388
expect(logContent).toContain("Cloning");
389389
expect(logContent.length).toBeGreaterThan(100);
390390
console.log("✅ Submodules deployment completed");
391391

392-
// Verificar imagen
392+
// Verify image
393393
const { stdout: dockerImages } = await execAsync(
394394
`docker images ${currentAppName} --format "{{.Repository}}"`,
395395
);
@@ -409,12 +409,12 @@ describe(
409409
descriptionLog: "",
410410
});
411411

412-
// Verificar que se llamó updateDeployment con info del commit
412+
// Verify updateDeployment was called with commit info
413413
expect(deploymentService.updateDeployment).toHaveBeenCalled();
414414
const updateCall = vi.mocked(deploymentService.updateDeployment).mock
415415
.calls[0];
416416

417-
// El commit info real debería tener título y hash
417+
// Real commit info should have title and hash
418418
expect(updateCall?.[1]).toHaveProperty("title");
419419
expect(updateCall?.[1]).toHaveProperty("description");
420420
expect(updateCall?.[1]?.description).toContain("Commit:");
@@ -456,15 +456,15 @@ describe(
456456

457457
expect(result).toBe(true);
458458

459-
// Verificar el log
459+
// Verify log
460460
const { stdout: logContent } = await execAsync(
461461
`cat ${currentDeployment.logPath}`,
462462
);
463463
expect(logContent).toContain("Building");
464464
expect(logContent).toContain(dockerfileAppName);
465465
console.log("✅ Dockerfile build log verified");
466466

467-
// Verificar imagen
467+
// Verify image
468468
const { stdout: dockerImages } = await execAsync(
469469
`docker images ${currentAppName} --format "{{.Repository}}"`,
470470
);

0 commit comments

Comments
 (0)