/**
 * Loads `.env.local` as a side effect on import.
 *
 * This has to be its own module: ES module imports are hoisted, so calling
 * `process.loadEnvFile()` at the top of a file that also imports the database
 * module would run *after* that module had already read `DATABASE_URL`. Imported
 * first, this module is evaluated first.
 *
 * It matters because the fallback connection string targets port 5432, which on
 * a development machine is quite likely another project's database.
 */
try {
  process.loadEnvFile(".env.local");
} catch {
  // No .env.local (CI, fresh clone): use the environment as given.
}

/**
 * Hard guarantee that the suite never sends mail.
 *
 * The fixtures operate on fabricated addresses (`authtest-…@gmail.com`), and a
 * configured SMTP server would dutifully try to deliver to them — bouncing off
 * real providers and burning the sending domain's reputation. Clearing these
 * puts the mailer into its development fallback, which returns the link instead
 * of sending it, which is also how the tests get hold of the raw token.
 */
delete process.env.SMTP_HOST;
delete process.env.SMTP_USER;
delete process.env.SMTP_PASSWORD;

// The dev fallback throws in production rather than silently not sending.
if (process.env.NODE_ENV === "production") {
  throw new Error("Refusing to run the auth integration suite with NODE_ENV=production");
}

export {};
