test: improve test-internal-fs-syncwritestream

A subtest about the behavior when `autoClose=false`.

PR-URL: https://github.com/nodejs/node/pull/54671
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Sunghoon 2024-09-14 23:31:13 +09:00 committed by GitHub
parent 3569493ba7
commit 415905712e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,6 +66,18 @@ const filename = tmpdir.resolve('sync-write-stream.txt');
assert.strictEqual(stream.fd, null);
}
// Verify that the file is not closed when autoClose=false
{
const fd = fs.openSync(filename, 'w');
const stream = new SyncWriteStream(fd, { autoClose: false });
stream.on('close', common.mustCall());
assert.strictEqual(stream.destroy(), stream);
fs.fstatSync(fd); // Does not throw
fs.closeSync(fd);
}
// Verify that calling end() will also destroy the stream.
{
const fd = fs.openSync(filename, 'w');