import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import test from "node:test"; import { fileURLToPath } from "node:url"; const fixtureSource = readFileSync( fileURLToPath(new URL("./helpers/postgres-fixture.ts", import.meta.url)), "utf8", ); test("postgres fixtures cap concurrent compose networks so Docker address pools cannot be exhausted", () => { assert.match(fixtureSource, /JYOTISHA_POSTGRES_MAX_FIXTURES/); assert.match(fixtureSource, /DEFAULT_MAX_CONCURRENT_POSTGRES_FIXTURES = 2/); assert.match(fixtureSource, /function acquireFixtureSlot\(/); assert.match(fixtureSource, /process\.kill\(\s*pid,\s*0\s*\)/); assert.match( fixtureSource, /export function startPostgresFixture\(\)[\s\S]*acquireFixtureSlot\(\)/, ); assert.match( fixtureSource, /timed out waiting for a PostgreSQL fixture slot/, ); }); test("postgres fixture start failure and stop both release the compose-network slot", () => { assert.match( fixtureSource, /catch \(error\) \{[\s\S]*releasePort\(portReservation\)[\s\S]*slot\.release\(\)/, ); assert.match( fixtureSource, /stop\(\) \{[\s\S]*releasePort\(portReservation\)[\s\S]*slot\.release\(\)/, ); });