mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00
test: add doAppendAndCancel test
PR-URL: https://github.com/nodejs/node/pull/56972 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
8f4d3069af
commit
685f00c073
@ -39,6 +39,21 @@ async function validateAppendString() {
|
|||||||
await fileHandle.close();
|
await fileHandle.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
validateAppendBuffer()
|
async function doAppendAndCancel() {
|
||||||
.then(validateAppendString)
|
const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
|
||||||
.then(common.mustCall());
|
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());
|
||||||
|
Loading…
Reference in New Issue
Block a user