Menu
popagent
publicLatest change b61deab8cc219052959fa9b2e7525335a79519f8 - Isolate tests and remove terminal tasks by AkurAI Build
type TestEnvironment = Partial<Record<
"POPAGENT_ISOLATED_TEST" | "DATABASE_URL" | "OBSERVABILITY_DATABASE_URL",
string
>>;
function isDisposableLocalDatabase(value: string | undefined): boolean {
if (!value) return false;
const url = new URL(value);
const local = url.hostname === "127.0.0.1" || url.hostname === "localhost";
return local && url.pathname.endsWith("_test");
}
export function assertIsolatedTestEnvironment(environment: TestEnvironment): void {
if (environment.POPAGENT_ISOLATED_TEST !== "1") {
throw new Error("Refusing to run tests outside the isolated runner; use ./deploy.sh test");
}
if (!isDisposableLocalDatabase(environment.DATABASE_URL)
|| !isDisposableLocalDatabase(environment.OBSERVABILITY_DATABASE_URL)) {
throw new Error("Tests require disposable test databases on localhost");
}
}