Skip to content

Commit

Permalink
test: improve test-internal-fs-syncwritestream
Browse files Browse the repository at this point in the history
A subtest about the behavior when `autoClose=false`.

PR-URL: #54671
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
sungpaks authored Sep 14, 2024
1 parent 3569493 commit 4159057
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/parallel/test-internal-fs-syncwritestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 4159057

Please sign in to comment.