/* c8 ignore start */
import { setMaxListeners } from "node:events";
import * as dotenv from "dotenv";
dotenv.config();
import why from "why-is-node-still-running";
import { isRedis } from "../data/index.js";
import { isKVConnect } from "../data/storage/kv-connect.js";
setMaxListeners(Number.MAX_SAFE_INTEGER);
const { isRedisMemory, startRedisMemory, stopData, stopRedisMemory } = await import("../data/index.js");
try {
    if (isRedisMemory()) {
        await startRedisMemory();
    }
    await import("./storage.js");
    await import("./schedule/index.js");
    await import("./cache.js");
    // Redis is a stable store... need to replace the default local
    // store for workers, but that is a later task
    if ((isRedis() || isKVConnect()) && typeof Bun === "undefined") {
        await import("./worker/index.js");
        await import("./readme/index.js");
    }
    // Ensure any data clients are closed
    await stopData();
    if (isRedisMemory()) {
        await stopRedisMemory();
    }
    console.log("Tests successful");
}
catch (error) {
    console.error(error);
    if (typeof process !== "undefined") {
        process.exit(1);
    }
    throw error;
}
if (process.env.TESTS_REPORT_HANDLES) {
    why.whyIsNodeStillRunning();
}
// Force closing, but reporting of handles above
process.exit(0);
export default 1;
//# sourceMappingURL=index.js.map