From: Ardis Lu Date: Fri, 7 Feb 2025 08:29:49 +0000 (-0800) Subject: Add test for saving progress on uncaught error X-Git-Tag: v0.1.0~68 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=fdd7390cd963c46fac7223a6be0ca5aa271b435f;p=csvio Add test for saving progress on uncaught error --- diff --git a/test/core.test.js b/test/core.test.js index 26bfa60..2839397 100644 --- a/test/core.test.js +++ b/test/core.test.js @@ -519,6 +519,22 @@ suite('CSVWriter', { concurrency: true }, () => { ['row 3', 'c'] ])); }); + test('flushes progress to disk on uncaught error', { concurrency: true }, async (t) => { + const temp = await createTempFile(); + t.after(async () => await unlink(temp)); + await rejects(async () => { + await ReadableStream.from((function* () { + yield '["header1","header2"]'; + yield '["1","1"]'; + throw new Error(); + })()).pipeTo(new CSVWriter(temp)) + }); + await new CSVReader(temp).pipeTo( + csvStreamEqualWritable([ + ['header1', 'header2'], + ['1', '1'], + ])); + }); }); suite('CSVWriter status', { concurrency: true }, () => {