// biome-ignore-all lint/suspicious/noEmptyBlockStatements: Allow empty blocks
import { mkdir, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { fastify } from "fastify";
/**
 * Creates a test Fastify instance with minimal configuration
 */
export async function createTestFastifyInstance() {
    const app = fastify({
        logger: false,
        ajv: {
            customOptions: {
                removeAdditional: "all",
                coerceTypes: true,
                useDefaults: true,
            },
        },
    });
    return app;
}
/**
 * Creates a temporary test directory with a unique name
 */
export async function createTempTestDir(prefix = "zuplo-test-") {
    const testDir = path.join(tmpdir(), `${prefix}${Date.now()}-${Math.random().toString(36).slice(2)}`);
    await mkdir(testDir, { recursive: true });
    return testDir;
}
/**
 * Removes a directory and all its contents
 */
export async function cleanupTestDir(dirPath) {
    try {
        await rm(dirPath, { recursive: true, force: true });
    }
    catch {
        // Ignore errors during cleanup
    }
}
/**
 * Creates a test file structure in the given directory
 */
export async function createTestFileStructure(baseDir) {
    // Create directories
    await mkdir(path.join(baseDir, "config"), { recursive: true });
    await mkdir(path.join(baseDir, "modules"), { recursive: true });
    await mkdir(path.join(baseDir, "schemas"), { recursive: true });
    await mkdir(path.join(baseDir, "tests"), { recursive: true });
    // Create test files
    await writeFile(path.join(baseDir, "config", "routes.json"), JSON.stringify({ routes: [] }, null, 2), "utf-8");
    await writeFile(path.join(baseDir, "modules", "my-handler.ts"), 'export default async function handler() { return "hello"; }', "utf-8");
    await writeFile(path.join(baseDir, "schemas", "schema.json"), JSON.stringify({ type: "object" }, null, 2), "utf-8");
}
/**
 * Mock logger for testing
 */
export const mockLogger = {
    info: () => { },
    error: () => { },
    warn: () => { },
    debug: () => { },
    trace: () => { },
    fatal: () => { },
};
//# sourceMappingURL=setup.js.map