Skip to content

Commit

Permalink
test: fs.write() if 3rd argument is a callback, not offset
Browse files Browse the repository at this point in the history
Easier way to resolve conflicts from #16822 and #16827.

PR-URL: #17045
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Patrick Heneise authored and addaleax committed Nov 18, 2017
1 parent 9531fcb commit 8f8999c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/parallel/test-fs-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const path = require('path');
const fs = require('fs');
const fn = path.join(common.tmpDir, 'write.txt');
const fn2 = path.join(common.tmpDir, 'write2.txt');
const fn3 = path.join(common.tmpDir, 'write3.txt');
const expected = 'ümlaut.';
const constants = fs.constants;

Expand Down Expand Up @@ -73,3 +74,15 @@ fs.open(fn2, args, 0o644, common.mustCall((err, fd) => {
fs.write(fd, '', 0, 'utf8', written);
fs.write(fd, expected, 0, 'utf8', done);
}));

fs.open(fn3, 'w', 0o644, common.mustCall(function(err, fd) {
assert.ifError(err);

const done = common.mustCall(function(err, written) {
assert.ifError(err);
assert.strictEqual(Buffer.byteLength(expected), written);
fs.closeSync(fd);
});

fs.write(fd, expected, done);
}));

0 comments on commit 8f8999c

Please sign in to comment.