import path from "node:path";
import {
  defineWorkersConfig,
  readD1Migrations,
} from "@cloudflare/vitest-pool-workers/config";

export default defineWorkersConfig(async () => {
  const migrations = await readD1Migrations(path.join(__dirname, "migrations"));
  return {
    test: {
      setupFiles: ["./test/apply-migrations.ts"],
      poolOptions: {
        workers: {
          wrangler: { configPath: "./wrangler.jsonc" },
          miniflare: {
            bindings: {
              TEST_MIGRATIONS: migrations,
              JWT_SECRET: "test-jwt-secret",
              WASABI_ACCESS_KEY_ID: "WASABITESTKEYID00000",
              WASABI_SECRET_ACCESS_KEY: "wasabi-test-secret-key",
            },
          },
        },
      },
    },
  };
});
