diff --git a/app/__test__/data/postgres.test.ts b/app/__test__/data/postgres.test.ts index 1560204d..cb04fda8 100644 --- a/app/__test__/data/postgres.test.ts +++ b/app/__test__/data/postgres.test.ts @@ -40,12 +40,17 @@ async function isPostgresRunning() { describe("postgres", () => { beforeAll(async () => { if (!(await isPostgresRunning())) { + // Only attempt to start container if port 5430 is not allocated by CI service + try { await $`docker run --rm --name bknd-test-postgres -d -e POSTGRES_PASSWORD=${credentials.password} -e POSTGRES_USER=${credentials.user} -e POSTGRES_DB=${credentials.database} -p ${credentials.port}:5432 postgres:17`; - await $waitUntil("Postgres is running", isPostgresRunning); - await new Promise((resolve) => setTimeout(resolve, 500)); + } catch (e) { + // Port allocated or docker unavailable; wait for CI service connection } + await $waitUntil("Postgres is running", isPostgresRunning); + await new Promise((resolve) => setTimeout(resolve, 500)); + } - disableConsoleLog(); + disableConsoleLog(); }); afterAll(async () => { if (await isPostgresRunning()) {