From 309a411718ac4d10e094af4a8511991fe37cf8d0 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Wed, 18 Feb 2026 11:55:55 -0600 Subject: [PATCH] delete: remove integration tests for patch generation and application --- .../patches/patch.integration.test.ts | 113 ------------------ 1 file changed, 113 deletions(-) delete mode 100644 apps/dokploy/__test__/patches/patch.integration.test.ts diff --git a/apps/dokploy/__test__/patches/patch.integration.test.ts b/apps/dokploy/__test__/patches/patch.integration.test.ts deleted file mode 100644 index 9efbc369f..000000000 --- a/apps/dokploy/__test__/patches/patch.integration.test.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { generatePatch } from "@dokploy/server/services/patch"; -import { describe, expect, it, afterEach } from "vitest"; -import { mkdtemp, rm, writeFile, readFile } from "node:fs/promises"; -import { join } from "node:path"; -import { tmpdir } from "node:os"; -import { exec } from "node:child_process"; -import { promisify } from "node:util"; - -const execAsyncLocal = promisify(exec); - -describe("Patch System Integration", () => { - let tempDir: string; - - afterEach(async () => { - if (tempDir) { - await rm(tempDir, { recursive: true, force: true }); - } - }); - - it("should generate a patch that can be successfully applied via git", async () => { - // Setup repo - tempDir = await mkdtemp(join(tmpdir(), "dokploy-patch-test-")); - const fileName = "test.txt"; - const filePath = join(tempDir, fileName); - - await execAsyncLocal("git init", { cwd: tempDir }); - await execAsyncLocal("git config user.email 'test@test.com'", { - cwd: tempDir, - }); - await execAsyncLocal("git config user.name 'Test'", { cwd: tempDir }); - - // Original content - await writeFile(filePath, "line1\nline2\n"); - await execAsyncLocal(`git add ${fileName}`, { cwd: tempDir }); - await execAsyncLocal("git commit -m 'init'", { cwd: tempDir }); - - // Generate patch (modify content) - const newContent = "line1\nline2\nline3\n"; - const patchContent = await generatePatch({ - codePath: tempDir, - filePath: fileName, - newContent, - serverId: null, - }); - - // Verify patch format - expect(patchContent.endsWith("\n")).toBe(true); - - // Reset file (generatePatch does reset, but ensure it) - await execAsyncLocal("git checkout .", { cwd: tempDir }); - const savedContent = await readFile(filePath, "utf-8"); - expect(savedContent).toBe("line1\nline2\n"); - - // Apply patch verification - // We simulate what Deployment Service does: write patch to file and run git apply - const patchFile = join(tempDir, "changes.patch"); - await writeFile(patchFile, patchContent); - - try { - await execAsyncLocal(`git apply --whitespace=fix ${patchFile}`, { - cwd: tempDir, - }); - } catch (e: any) { - console.error("Git apply failed:", e.message); - console.log("Patch content:", JSON.stringify(patchContent)); - throw e; - } - - const appliedContent = await readFile(filePath, "utf-8"); - expect(appliedContent).toBe(newContent); - }); - - it("should handle files created without trailing newline", async () => { - // Setup repo - tempDir = await mkdtemp(join(tmpdir(), "dokploy-patch-test-noline-")); - const fileName = "noline.txt"; - const filePath = join(tempDir, fileName); - - await execAsyncLocal("git init", { cwd: tempDir }); - await execAsyncLocal("git config user.email 'test@test.com'", { - cwd: tempDir, - }); - await execAsyncLocal("git config user.name 'Test'", { cwd: tempDir }); - - // Original content WITHOUT newline - await writeFile(filePath, "line1"); - await execAsyncLocal(`git add ${fileName}`, { cwd: tempDir }); - await execAsyncLocal("git commit -m 'init'", { cwd: tempDir }); - - // Generate patch - const newContent = "line1\nline2"; - const patchContent = await generatePatch({ - codePath: tempDir, - filePath: fileName, - newContent, - serverId: null, - }); - - // Verify patch format - expect(patchContent.endsWith("\n")).toBe(true); - - // Apply patch - const patchFile = join(tempDir, "changes.patch"); - await writeFile(patchFile, patchContent); - - await execAsyncLocal(`git apply --whitespace=fix ${patchFile}`, { - cwd: tempDir, - }); - - const appliedContent = await readFile(filePath, "utf-8"); - expect(appliedContent).toBe(newContent); - }); -});