delete(tests): remove mock database setup file and update Vitest configuration

- Deleted the mock database setup file to streamline the test environment.
- Updated the Vitest configuration to remove the reference to the deleted setup file, enhancing clarity in test setup.
This commit is contained in:
Mauricio Siu
2026-02-05 01:17:04 -06:00
parent bde192c1e7
commit 2746133252
2 changed files with 0 additions and 67 deletions

View File

@@ -1,66 +0,0 @@
import { vi } from "vitest";
// Mock postgres to prevent actual database connections
vi.mock("postgres", () => {
return {
default: vi.fn(() => ({
end: vi.fn(),
unsafe: vi.fn(),
})),
};
});
// Mock the db export from @dokploy/server/db
vi.mock("@dokploy/server/db", () => {
const createChainableMock = (): any => {
const chain: any = {
set: vi.fn(() => chain),
where: vi.fn(() => chain),
values: vi.fn(() => chain),
returning: vi.fn().mockResolvedValue([{}]),
execute: vi.fn().mockResolvedValue([{}]),
};
return chain;
};
return {
db: {
select: vi.fn(() => createChainableMock()),
insert: vi.fn(() => createChainableMock()),
update: vi.fn(() => createChainableMock()),
delete: vi.fn(() => createChainableMock()),
query: {
applications: {
findFirst: vi.fn(),
findMany: vi.fn(),
},
deployments: {
findFirst: vi.fn(),
findMany: vi.fn(),
},
servers: {
findFirst: vi.fn(),
findMany: vi.fn(),
},
users: {
findFirst: vi.fn(),
findMany: vi.fn(),
},
organizations: {
findFirst: vi.fn(),
findMany: vi.fn(),
},
// Necesario para getWebServerSettings (lib/auth -> trustedOrigins)
webServerSettings: {
findFirst: vi.fn().mockResolvedValue(null),
findMany: vi.fn().mockResolvedValue([]),
},
member: {
findFirst: vi.fn(),
findMany: vi.fn(),
},
},
},
dbUrl: "postgres://mock:mock@localhost:5432/mock",
};
});

View File

@@ -8,7 +8,6 @@ export default defineConfig({
exclude: ["**/node_modules/**", "**/dist/**", "**/.docker/**"],
pool: "forks",
// Se ejecuta antes de todos los tests y aplica mocks globales (db, postgres, etc.)
setupFiles: ["./__test__/setup/mock-db.ts"],
},
define: {
"process.env": {