Files
photoreport/apps/api/test/guard.ts
sparkandClaude Opus 5.5 59c0c34af7
ci / rust (push) Failing after 54s
ci / typescript (push) Failing after 1m8s
feat(api): members, preferences, errors and auth tests (3/10)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-11 14:42:28 +01:00

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;
}