import { postgresAdapter } from '@payloadcms/db-postgres' import { sqliteAdapter } from '@payloadcms/db-sqlite' /** * The database of the HTTP security tests. SQLite in memory by default; `IPAL_TEST_POSTGRES_URI` points them at a * real Postgres (numeric ids, like SQLite — the adapters where an id of one auth collection can equal an id of * another): * docker run -d --rm -p 127.0.0.1:55432:5432 -e POSTGRES_PASSWORD=test postgres:17 * IPAL_TEST_POSTGRES_URI=postgres://postgres:test@127.0.0.1:55432/postgres pnpm vitest run test/securityHttp.test.ts * Each test file gets its own schema (`name`), so the files can run one after another against one server. */ export function testDatabase(name: string) { const uri = process.env.IPAL_TEST_POSTGRES_URI if (uri) {return postgresAdapter({ pool: { connectionString: uri }, push: true, schemaName: `${name}_${Date.now()}` })} return sqliteAdapter({ client: { url: 'file::memory:' }, push: true }) }