Skip to content

Commit 79ba863

Browse files
Patrick HeneiseMylesBorins
Patrick Heneise
authored andcommitted
test: fs.write() if 3rd argument is a callback, not offset
Easier way to resolve conflicts from #16822 and #16827. PR-URL: #17045 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 4b35dfb commit 79ba863

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/parallel/test-fs-write.js

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const path = require('path');
2626
const fs = require('fs');
2727
const fn = path.join(common.tmpDir, 'write.txt');
2828
const fn2 = path.join(common.tmpDir, 'write2.txt');
29+
const fn3 = path.join(common.tmpDir, 'write3.txt');
2930
const expected = 'ümlaut.';
3031
const constants = fs.constants;
3132

@@ -73,3 +74,15 @@ fs.open(fn2, args, 0o644, common.mustCall((err, fd) => {
7374
fs.write(fd, '', 0, 'utf8', written);
7475
fs.write(fd, expected, 0, 'utf8', done);
7576
}));
77+
78+
fs.open(fn3, 'w', 0o644, common.mustCall(function(err, fd) {
79+
assert.ifError(err);
80+
81+
const done = common.mustCall(function(err, written) {
82+
assert.ifError(err);
83+
assert.strictEqual(Buffer.byteLength(expected), written);
84+
fs.closeSync(fd);
85+
});
86+
87+
fs.write(fd, expected, done);
88+
}));

0 commit comments

Comments
 (0)