Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
8 lines
434 B
TypeScript
8 lines
434 B
TypeScript
/** 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;
|
|
}
|