Skip to content

Commit 6bbe2fa

Browse files
y-hsgwaduh95
authored andcommitted
test: add doAppendAndCancel test
PR-URL: #56972 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 277caa6 commit 6bbe2fa

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

test/parallel/test-fs-promises-file-handle-append-file.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ async function validateAppendString() {
3939
await fileHandle.close();
4040
}
4141

42-
validateAppendBuffer()
43-
.then(validateAppendString)
44-
.then(common.mustCall());
42+
async function doAppendAndCancel() {
43+
const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
44+
const fileHandle = await open(filePathForHandle, 'w+');
45+
const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8');
46+
const controller = new AbortController();
47+
const { signal } = controller;
48+
process.nextTick(() => controller.abort());
49+
await assert.rejects(fileHandle.appendFile(buffer, { signal }), {
50+
name: 'AbortError'
51+
});
52+
await fileHandle.close();
53+
}
54+
55+
Promise.all([
56+
validateAppendBuffer(),
57+
validateAppendString(),
58+
doAppendAndCancel(),
59+
]).then(common.mustCall());

0 commit comments

Comments
 (0)