diff --git a/__tests__/__snapshots__/migrate.test.ts.snap b/__tests__/__snapshots__/migrate.test.ts.snap index 68d7465..e69339b 100644 --- a/__tests__/__snapshots__/migrate.test.ts.snap +++ b/__tests__/__snapshots__/migrate.test.ts.snap @@ -2,6 +2,28 @@ exports[`handles errors during migration gracefully 1`] = `[error: division by zero]`; +exports[`handles errors during migration gracefully 2`] = ` +" +🛑 Error occurred whilst processing migration + error: division by zero + at ~/node_modules/pg/lib/client.js:[LINE]:[COL] + at processTicksAndRejections (node:internal/process/task_queues:[LINE]:[COL]) + at runQueryWithErrorInstrumentation (~/src/instrumentation.ts:[LINE]:[COL]) + at ~/src/migration.ts:[LINE]:[COL] + at withAdvisoryLock (~/src/pgReal.ts:[LINE]:[COL]) + at runCommittedMigration (~/src/migration.ts:[LINE]:[COL]) + at ~/src/commands/migrate.ts:[LINE]:[COL] + at withAdvisoryLock (~/src/pgReal.ts:[LINE]:[COL]) + at ~/src/commands/migrate.ts:[LINE]:[COL] + at withClient (~/src/pgReal.ts:[LINE]:[COL]) + at _migrate (~/src/commands/migrate.ts:[LINE]:[COL]) + at Object. (~/__tests__/migrate.test.ts:[LINE]:[COL]) + + Severity: ERROR + Code: 22012 +,[object Object]" +`; + exports[`refuses to run migration with invalid hash 1`] = `"Hash for 000002.sql does not match - sha1:cbed240dda7dfa510ff785783bbe6af7743b3a11 !== sha1:bddc1ead3310dc1c42cdc7f63537ebdff2e9fd7b; has the file been tampered with?"`; exports[`runs migrations 1`] = ` diff --git a/__tests__/migrate.test.ts b/__tests__/migrate.test.ts index 64dbd77..907419a 100644 --- a/__tests__/migrate.test.ts +++ b/__tests__/migrate.test.ts @@ -178,5 +178,9 @@ comment on table frogs is 'Ribbit'; logDbError(parsedSettings, err); expect(mock).toHaveBeenCalledTimes(1); const call = mock.mock.calls[0]; - expect(call).toMatchSnapshot(); + expect( + String(call) + .replaceAll(process.cwd(), "~") + .replace(/:[0-9]+:[0-9]+($|\))/gm, ":[LINE]:[COL]$1"), + ).toMatchSnapshot(); });