45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
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\(\)/,
|
|
);
|
|
});
|
|
|
|
test("large PostgreSQL scripts use stdin without changing shared -c helpers", () => {
|
|
assert.match(fixtureSource, /psqlScriptAs\(role, password, sql\)/);
|
|
assert.match(fixtureSource, /psqlScriptAs[\s\S]*input: sql/);
|
|
assert.match(fixtureSource, /psqlScriptAs[\s\S]*maxBuffer: 16 \* 1024 \* 1024/);
|
|
assert.match(fixtureSource, /psqlScriptAs[\s\S]*"--single-transaction"[\s\S]*"-f"[\s\S]*"-"/);
|
|
assert.match(fixtureSource, /psql\(sql\)[\s\S]*"-Atc",\s*sql/);
|
|
assert.match(fixtureSource, /psqlAs\(role, password, sql\)[\s\S]*"-Atc",\s*sql/);
|
|
});
|