]> git.ardis.lu - csvio/commitdiff
Add test for saving progress on uncaught error
authorArdis Lu <ardisglu@gmail.com>
Fri, 7 Feb 2025 08:29:49 +0000 (00:29 -0800)
committerArdis Lu <ardisglu@gmail.com>
Fri, 7 Feb 2025 08:29:49 +0000 (00:29 -0800)
test/core.test.js

index 26bfa606c288ff30de2fbe09a7a3641d4a432732..283939767a49f4a69835cced61baea2f54673d8f 100644 (file)
@@ -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 }, () => {
This page took 0.040387 seconds and 4 git commands to generate.