Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pgpm/export/__tests__/export-parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions postgres/pgsql-test/__tests__/postgres-test.seed-failures.test.ts
Original file line number Diff line number Diff line change
@@ -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/);
});
10 changes: 8 additions & 2 deletions postgres/pgsql-test/src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}

Expand Down
Loading