Skip to content

Commit

Permalink
test: add doAppendAndCancel test
Browse files Browse the repository at this point in the history
PR-URL: #56972
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
y-hsgw authored and targos committed Feb 25, 2025
1 parent f35bd86 commit 1a24417
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test/parallel/test-fs-promises-file-handle-append-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ async function validateAppendString() {
await fileHandle.close();
}

validateAppendBuffer()
.then(validateAppendString)
.then(common.mustCall());
async function doAppendAndCancel() {
const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
const fileHandle = await open(filePathForHandle, 'w+');
const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8');
const controller = new AbortController();
const { signal } = controller;
process.nextTick(() => controller.abort());
await assert.rejects(fileHandle.appendFile(buffer, { signal }), {
name: 'AbortError'
});
await fileHandle.close();
}

Promise.all([
validateAppendBuffer(),
validateAppendString(),
doAppendAndCancel(),
]).then(common.mustCall());

0 comments on commit 1a24417

Please sign in to comment.