mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: restore commented-out test cases and imports in drop.test.test.ts for improved functionality
Some checks failed
Auto PR to main when version changes / create-pr (push) Has been cancelled
Build Docker images / build-and-push-cloud-image (push) Has been cancelled
Build Docker images / build-and-push-schedule-image (push) Has been cancelled
Build Docker images / build-and-push-server-image (push) Has been cancelled
Dokploy Docker Build / docker-amd (push) Has been cancelled
Dokploy Docker Build / docker-arm (push) Has been cancelled
autofix.ci / format (push) Has been cancelled
Dokploy Monitoring Build / docker-amd (push) Has been cancelled
Dokploy Monitoring Build / docker-arm (push) Has been cancelled
Dokploy Docker Build / combine-manifests (push) Has been cancelled
Dokploy Docker Build / generate-release (push) Has been cancelled
Dokploy Monitoring Build / combine-manifests (push) Has been cancelled
Some checks failed
Auto PR to main when version changes / create-pr (push) Has been cancelled
Build Docker images / build-and-push-cloud-image (push) Has been cancelled
Build Docker images / build-and-push-schedule-image (push) Has been cancelled
Build Docker images / build-and-push-server-image (push) Has been cancelled
Dokploy Docker Build / docker-amd (push) Has been cancelled
Dokploy Docker Build / docker-arm (push) Has been cancelled
autofix.ci / format (push) Has been cancelled
Dokploy Monitoring Build / docker-amd (push) Has been cancelled
Dokploy Monitoring Build / docker-arm (push) Has been cancelled
Dokploy Docker Build / combine-manifests (push) Has been cancelled
Dokploy Docker Build / generate-release (push) Has been cancelled
Dokploy Monitoring Build / combine-manifests (push) Has been cancelled
This commit is contained in:
parent
46d12fa9d8
commit
2619cb49d1
@ -1,155 +1,156 @@
|
|||||||
// import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
// import path from "node:path";
|
import path from "node:path";
|
||||||
// import { paths } from "@dokploy/server/constants";
|
import { paths } from "@dokploy/server/constants";
|
||||||
// const { APPLICATIONS_PATH } = paths();
|
const { APPLICATIONS_PATH } = paths();
|
||||||
// import type { ApplicationNested } from "@dokploy/server";
|
import type { ApplicationNested } from "@dokploy/server";
|
||||||
// import { unzipDrop } from "@dokploy/server";
|
import { unzipDrop } from "@dokploy/server";
|
||||||
// import AdmZip from "adm-zip";
|
import AdmZip from "adm-zip";
|
||||||
// import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
// vi.mock("@dokploy/server/constants", async (importOriginal) => {
|
vi.mock("@dokploy/server/constants", async (importOriginal) => {
|
||||||
// const actual = await importOriginal();
|
const actual = await importOriginal();
|
||||||
// return {
|
return {
|
||||||
// // @ts-ignore
|
// @ts-ignore
|
||||||
// ...actual,
|
...actual,
|
||||||
// paths: () => ({
|
paths: () => ({
|
||||||
// APPLICATIONS_PATH: "./__test__/drop/zips/output",
|
APPLICATIONS_PATH: "./__test__/drop/zips/output",
|
||||||
// }),
|
}),
|
||||||
// };
|
};
|
||||||
// });
|
});
|
||||||
|
|
||||||
// if (typeof window === "undefined") {
|
if (typeof window === "undefined") {
|
||||||
// const undici = require("undici");
|
const undici = require("undici");
|
||||||
// globalThis.File = undici.File as any;
|
globalThis.File = undici.File as any;
|
||||||
// globalThis.FileList = undici.FileList as any;
|
globalThis.FileList = undici.FileList as any;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const baseApp: ApplicationNested = {
|
const baseApp: ApplicationNested = {
|
||||||
// applicationId: "",
|
applicationId: "",
|
||||||
// herokuVersion: "",
|
herokuVersion: "",
|
||||||
// giteaBranch: "",
|
giteaBranch: "",
|
||||||
// giteaBuildPath: "",
|
giteaBuildPath: "",
|
||||||
// giteaId: "",
|
giteaId: "",
|
||||||
// giteaOwner: "",
|
giteaOwner: "",
|
||||||
// giteaRepository: "",
|
giteaRepository: "",
|
||||||
// cleanCache: false,
|
cleanCache: false,
|
||||||
// watchPaths: [],
|
watchPaths: [],
|
||||||
// enableSubmodules: false,
|
enableSubmodules: false,
|
||||||
// applicationStatus: "done",
|
applicationStatus: "done",
|
||||||
// triggerType: "push",
|
triggerType: "push",
|
||||||
// appName: "",
|
appName: "",
|
||||||
// autoDeploy: true,
|
autoDeploy: true,
|
||||||
// serverId: "",
|
serverId: "",
|
||||||
// registryUrl: "",
|
registryUrl: "",
|
||||||
// branch: null,
|
branch: null,
|
||||||
// dockerBuildStage: "",
|
dockerBuildStage: "",
|
||||||
// isPreviewDeploymentsActive: false,
|
isPreviewDeploymentsActive: false,
|
||||||
// previewBuildArgs: null,
|
previewBuildArgs: null,
|
||||||
// previewCertificateType: "none",
|
previewCertificateType: "none",
|
||||||
// previewCustomCertResolver: null,
|
previewCustomCertResolver: null,
|
||||||
// previewEnv: null,
|
previewEnv: null,
|
||||||
// previewHttps: false,
|
previewHttps: false,
|
||||||
// previewPath: "/",
|
previewPath: "/",
|
||||||
// previewPort: 3000,
|
previewPort: 3000,
|
||||||
// previewLimit: 0,
|
previewLimit: 0,
|
||||||
// previewWildcard: "",
|
previewWildcard: "",
|
||||||
// project: {
|
project: {
|
||||||
// env: "",
|
env: "",
|
||||||
// organizationId: "",
|
organizationId: "",
|
||||||
// name: "",
|
name: "",
|
||||||
// description: "",
|
description: "",
|
||||||
// createdAt: "",
|
createdAt: "",
|
||||||
// projectId: "",
|
projectId: "",
|
||||||
// },
|
},
|
||||||
// buildArgs: null,
|
buildArgs: null,
|
||||||
// buildPath: "/",
|
buildPath: "/",
|
||||||
// gitlabPathNamespace: "",
|
gitlabPathNamespace: "",
|
||||||
// buildType: "nixpacks",
|
buildType: "nixpacks",
|
||||||
// bitbucketBranch: "",
|
bitbucketBranch: "",
|
||||||
// bitbucketBuildPath: "",
|
bitbucketBuildPath: "",
|
||||||
// bitbucketId: "",
|
bitbucketId: "",
|
||||||
// bitbucketRepository: "",
|
bitbucketRepository: "",
|
||||||
// bitbucketOwner: "",
|
bitbucketOwner: "",
|
||||||
// githubId: "",
|
githubId: "",
|
||||||
// gitlabProjectId: 0,
|
gitlabProjectId: 0,
|
||||||
// gitlabBranch: "",
|
gitlabBranch: "",
|
||||||
// gitlabBuildPath: "",
|
gitlabBuildPath: "",
|
||||||
// gitlabId: "",
|
gitlabId: "",
|
||||||
// gitlabRepository: "",
|
gitlabRepository: "",
|
||||||
// gitlabOwner: "",
|
gitlabOwner: "",
|
||||||
// command: null,
|
command: null,
|
||||||
// cpuLimit: null,
|
cpuLimit: null,
|
||||||
// cpuReservation: null,
|
cpuReservation: null,
|
||||||
// createdAt: "",
|
createdAt: "",
|
||||||
// customGitBranch: "",
|
customGitBranch: "",
|
||||||
// customGitBuildPath: "",
|
customGitBuildPath: "",
|
||||||
// customGitSSHKeyId: null,
|
customGitSSHKeyId: null,
|
||||||
// customGitUrl: "",
|
customGitUrl: "",
|
||||||
// description: "",
|
description: "",
|
||||||
// dockerfile: null,
|
dockerfile: null,
|
||||||
// dockerImage: null,
|
dockerImage: null,
|
||||||
// dropBuildPath: null,
|
dropBuildPath: null,
|
||||||
// enabled: null,
|
enabled: null,
|
||||||
// env: null,
|
env: null,
|
||||||
// healthCheckSwarm: null,
|
healthCheckSwarm: null,
|
||||||
// labelsSwarm: null,
|
labelsSwarm: null,
|
||||||
// memoryLimit: null,
|
memoryLimit: null,
|
||||||
// memoryReservation: null,
|
memoryReservation: null,
|
||||||
// modeSwarm: null,
|
modeSwarm: null,
|
||||||
// mounts: [],
|
mounts: [],
|
||||||
// name: "",
|
name: "",
|
||||||
// networkSwarm: null,
|
networkSwarm: null,
|
||||||
// owner: null,
|
owner: null,
|
||||||
// password: null,
|
password: null,
|
||||||
// placementSwarm: null,
|
placementSwarm: null,
|
||||||
// ports: [],
|
ports: [],
|
||||||
// projectId: "",
|
projectId: "",
|
||||||
// publishDirectory: null,
|
publishDirectory: null,
|
||||||
// isStaticSpa: null,
|
isStaticSpa: null,
|
||||||
// redirects: [],
|
redirects: [],
|
||||||
// refreshToken: "",
|
refreshToken: "",
|
||||||
// registry: null,
|
registry: null,
|
||||||
// registryId: null,
|
registryId: null,
|
||||||
// replicas: 1,
|
replicas: 1,
|
||||||
// repository: null,
|
repository: null,
|
||||||
// restartPolicySwarm: null,
|
restartPolicySwarm: null,
|
||||||
// rollbackConfigSwarm: null,
|
rollbackConfigSwarm: null,
|
||||||
// security: [],
|
security: [],
|
||||||
// sourceType: "git",
|
sourceType: "git",
|
||||||
// subtitle: null,
|
subtitle: null,
|
||||||
// title: null,
|
title: null,
|
||||||
// updateConfigSwarm: null,
|
updateConfigSwarm: null,
|
||||||
// username: null,
|
username: null,
|
||||||
// dockerContextPath: null,
|
dockerContextPath: null,
|
||||||
// };
|
};
|
||||||
|
|
||||||
// describe("unzipDrop using real zip files", () => {
|
describe("unzipDrop using real zip files", () => {
|
||||||
// // const { APPLICATIONS_PATH } = paths();
|
// const { APPLICATIONS_PATH } = paths();
|
||||||
// beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// await fs.rm(APPLICATIONS_PATH, { recursive: true, force: true });
|
await fs.rm(APPLICATIONS_PATH, { recursive: true, force: true });
|
||||||
// });
|
});
|
||||||
|
|
||||||
// afterAll(async () => {
|
afterAll(async () => {
|
||||||
// await fs.rm(APPLICATIONS_PATH, { recursive: true, force: true });
|
await fs.rm(APPLICATIONS_PATH, { recursive: true, force: true });
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it("should correctly extract a zip with a single root folder", async () => {
|
it("should correctly extract a zip with a single root folder", async () => {
|
||||||
// baseApp.appName = "single-file";
|
baseApp.appName = "single-file";
|
||||||
// // const appName = "single-file";
|
// const appName = "single-file";
|
||||||
// try {
|
try {
|
||||||
// const outputPath = path.join(APPLICATIONS_PATH, baseApp.appName, "code");
|
const outputPath = path.join(APPLICATIONS_PATH, baseApp.appName, "code");
|
||||||
// const zip = new AdmZip("./__test__/drop/zips/single-file.zip");
|
const zip = new AdmZip("./__test__/drop/zips/single-file.zip");
|
||||||
// console.log(`Output Path: ${outputPath}`);
|
console.log(`Output Path: ${outputPath}`);
|
||||||
// const zipBuffer = zip.toBuffer();
|
const zipBuffer = zip.toBuffer();
|
||||||
// const file = new File([zipBuffer], "single.zip");
|
const file = new File([zipBuffer], "single.zip");
|
||||||
// await unzipDrop(file, baseApp);
|
await unzipDrop(file, baseApp);
|
||||||
// const files = await fs.readdir(outputPath, { withFileTypes: true });
|
const files = await fs.readdir(outputPath, { withFileTypes: true });
|
||||||
// expect(files.some((f) => f.name === "test.txt")).toBe(true);
|
expect(files.some((f) => f.name === "test.txt")).toBe(true);
|
||||||
// } catch (err) {
|
} catch (err) {
|
||||||
// console.log(err);
|
console.log(err);
|
||||||
// } finally {
|
} finally {
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// it("should correctly extract a zip with a single root folder and a subfolder", async () => {
|
// it("should correctly extract a zip with a single root folder and a subfolder", async () => {
|
||||||
// baseApp.appName = "folderwithfile";
|
// baseApp.appName = "folderwithfile";
|
||||||
|
Loading…
Reference in New Issue
Block a user