From 2fcfd0cb2e76c67b39e8497ad12d176198476eb2 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sun, 23 Aug 2026 22:46:10 +0000 Subject: [PATCH 1/2] fix(pgsql-test): fail the harness when seeding fails --- .../postgres-test.seed-failures.test.ts | 26 +++++++++++++++++++ postgres/pgsql-test/src/connect.ts | 10 +++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 postgres/pgsql-test/__tests__/postgres-test.seed-failures.test.ts diff --git a/postgres/pgsql-test/__tests__/postgres-test.seed-failures.test.ts b/postgres/pgsql-test/__tests__/postgres-test.seed-failures.test.ts new file mode 100644 index 000000000..60833cf9e --- /dev/null +++ b/postgres/pgsql-test/__tests__/postgres-test.seed-failures.test.ts @@ -0,0 +1,26 @@ +process.env.LOG_SCOPE = 'pgsql-test'; + +import { seed } from '../src'; +import { getConnections } from '../src/connect'; + +jest.setTimeout(30000); + +it('fails the harness when a seed adapter throws', async () => { + await expect( + getConnections({}, [ + seed.fn(async () => { + throw new Error('DELIBERATE_SEED_FAILURE'); + }) + ]) + ).rejects.toThrow('DELIBERATE_SEED_FAILURE'); +}); + +it('fails the harness when seed SQL is invalid', async () => { + await expect( + getConnections({}, [ + seed.fn(async ({ pg }) => { + await pg.query('SELECT * FROM a_relation_that_does_not_exist'); + }) + ]) + ).rejects.toThrow(/a_relation_that_does_not_exist/); +}); diff --git a/postgres/pgsql-test/src/connect.ts b/postgres/pgsql-test/src/connect.ts index 518ff3cad..6ec7ae4d0 100644 --- a/postgres/pgsql-test/src/connect.ts +++ b/postgres/pgsql-test/src/connect.ts @@ -116,8 +116,14 @@ export const getConnections = async ( } catch (error) { // Format the error with PostgreSQL extended fields for better debugging const formatted = formatPgError(error); - process.stderr.write(`[pgsql-test] Seed error (continuing):\n${formatted}\n`); - // continue without teardown to allow caller-managed lifecycle + process.stderr.write(`[pgsql-test] Seed failed:\n${formatted}\n`); + try { + await teardown(); + } catch { + // Teardown of a database we are already abandoning: the seed error below + // is the actionable one, and hiding it behind a cleanup failure is worse. + } + throw new Error(`[pgsql-test] Seed failed:\n${formatted}`, { cause: error }); } } From 61acb80a13b7c19a0f3eb22e7e7e7014b91eac7f Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sun, 23 Aug 2026 23:05:42 +0000 Subject: [PATCH 2/2] test(export): scope deploy file assertion to database module --- pgpm/export/__tests__/export-parity.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgpm/export/__tests__/export-parity.test.ts b/pgpm/export/__tests__/export-parity.test.ts index ac87d0b49..8add04777 100644 --- a/pgpm/export/__tests__/export-parity.test.ts +++ b/pgpm/export/__tests__/export-parity.test.ts @@ -676,7 +676,7 @@ describe('export parity — SQL vs GraphQL (integration)', () => { } // Sanity: at least 105 deploy files were produced (one per sql_action) - const deployFiles = sqlPaths.filter(p => p.includes(EXTENSION_NAME) && p.includes('/deploy/')); + const deployFiles = sqlPaths.filter(p => p.startsWith(`${EXTENSION_NAME}/deploy/`)); expect(deployFiles.length).toBe(TOTAL_ACTIONS); // Cleanup