Skip to content

Commit 1a24417

Browse files
y-hsgwtargos
authored andcommitted
test: add doAppendAndCancel test
PR-URL: #56972 Reviewed-By: Luigi Pinca <[email protected]>
1 parent f35bd86 commit 1a24417

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‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ async function validateAppendString(){
3939
awaitfileHandle.close();
4040
}
4141

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

0 commit comments

Comments
(0)