fix(backup): name the client tool when pg_restore cannot read a Postgres dump

A missing pg_restore, or one older than the pg_dump that wrote the archive, was reported as an invalid dump. The refusal now says which tool to install or point TREK_DB_PG_BIN_DIR at.
This commit is contained in:
Maurice
2026-11-23 14:57:20 +01:00
parent 89da19e535
commit bf8677a28c
2 changed files with 31 additions and 1 deletions
@@ -203,4 +203,16 @@ describe('PostgresDatabaseBackup', () => {
installFakeTool(bin, 'pg_restore', { snippets: [listsMigrations(['Migration20990101000000_from_the_future'])] });
await expect(backup.checkCopy(copy)).resolves.toMatch(/made by a newer TREK version/);
});
it('PGBACKUP-008: a dump pg_restore cannot read for its own reasons names the tool, not the file', async () => {
const copy = path.join(root, 'travel.pgdump');
writeFileSync(copy, 'dump');
vi.spyOn(console, 'warn').mockImplementation(() => undefined);
await expect(backup.checkCopy(copy)).resolves.toMatch(/^pg_restore was not found/);
installFakeTool(bin, 'pg_restore', {
snippets: [failsWith('pg_restore: error: unsupported version (1.16) in file header')],
});
await expect(backup.checkCopy(copy)).resolves.toMatch(/written by a newer pg_dump than the pg_restore/);
});
});