/** Guards destructive test helpers: only databases whose name ends in `_test` may be truncated. */ export function assertTestDatabase(url: string | undefined): string { if (!url) throw new Error("DATABASE_URL_TEST is required for API tests"); const name = new URL(url).pathname.replace(/^\//, ""); if (!name.endsWith("_test")) throw new Error(`Refusing to run tests against "${name}": name must end in _test`); return url; }