diff --git a/src/index.ts b/src/index.ts index 3ca0376..551ff51 100644 --- a/src/index.ts +++ b/src/index.ts @@ -55,7 +55,6 @@ export const getTestPostgresDatabaseFactory = < >( options?: GetTestPostgresDatabaseFactoryOptions ) => { - console.log("options", options) const initialData: InitialWorkerData = { postgresVersion: options?.postgresVersion ?? "14", containerOptions: options?.container, diff --git a/src/tests/pgbouncer.test.ts b/src/tests/pgbouncer.test.ts index ba3dbda..0a72e26 100644 --- a/src/tests/pgbouncer.test.ts +++ b/src/tests/pgbouncer.test.ts @@ -8,11 +8,23 @@ test("pgbouncer", async (t) => { pgbouncer: { enabled: true, version: "1.22.0", + poolMode: "statement", }, }) const postgres13 = await getPostgres13(t) t.truthy(postgres13.pgbouncerConnectionString) - await postgres13.pool.query("SELECT 1") + const result = await postgres13.pool.query("SELECT 1 as result") + + t.is(result.rows[0].result, 1) + + // can't use a transaction with statement pool mode + const err = await t.throwsAsync(postgres13.pool.query(`BEGIN TRANSACTION`)) + + t.truthy( + err! + .toString() + .includes("transaction blocks not allowed in statement pooling mode") + ) }) diff --git a/src/worker-wrapper.ts b/src/worker-wrapper.ts index 96f705d..eb9f8ec 100644 --- a/src/worker-wrapper.ts +++ b/src/worker-wrapper.ts @@ -18,7 +18,6 @@ const workerWrapper = async ( const { initialData } = protocol - console.log("creating worker with initialData", initialData) const worker = new Worker(initialData as any) for await (const testWorker of protocol.testWorkers()) { diff --git a/src/worker.ts b/src/worker.ts index a685664..bbf7766 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -320,13 +320,12 @@ export class Worker { )}/postgres` let startedPgbouncerContainer - console.log("pgbouncerOptions", this.initialData.pgbouncerOptions) if (this.initialData.pgbouncerOptions?.enabled) { const pgbouncerContainer = new GenericContainer("edoburu/pgbouncer") .withExposedPorts(6432) .withName(getRandomDatabaseName()) .withEnvironment({ - DB_HOST: startedContainer.getHost(), + DB_HOST: startedContainer.getName().replace("/", ""), DB_USER: "postgres", DB_NAME: "*", POOL_MODE: @@ -336,9 +335,7 @@ export class Worker { }) .withStartupTimeout(120_000) .withNetwork(network) - console.log("attempting to start pg bouncer") startedPgbouncerContainer = await pgbouncerContainer.start() - console.log("finishing starting pg bouncer") } return {