summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-truncate.js
diff options
context:
space:
mode:
authorVinícius do Carmo <vinicius.m.do.carmo@gmail.com>2017-01-24 00:58:00 -0300
committerMichael Dawson <michael_dawson@ca.ibm.com>2017-01-26 11:36:08 -0500
commitefbda74686e51525517ec2f89b75039d1db57e59 (patch)
tree0b42afc9f0de759644f813b1bc966c1f31f71e25 /test/parallel/test-fs-truncate.js
parentf73bc91756373f4057b3fc139dc5968049fa8c2a (diff)
downloadandroid-node-v8-efbda74686e51525517ec2f89b75039d1db57e59.tar.gz
android-node-v8-efbda74686e51525517ec2f89b75039d1db57e59.tar.bz2
android-node-v8-efbda74686e51525517ec2f89b75039d1db57e59.zip
test: expand test coverage of fs.js
* test calling truncateSync() passing a file descriptor * test calling truncate() passing undefined as the 2nd argument Refs: https://coverage.nodejs.org/coverage-8ab561b2432bdae3/root/fs.js.html (line 673 and 692) PR-URL: https://github.com/nodejs/node/pull/10972 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/parallel/test-fs-truncate.js')
-rw-r--r--test/parallel/test-fs-truncate.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/parallel/test-fs-truncate.js b/test/parallel/test-fs-truncate.js
index 80c938b8d4..57d706bddb 100644
--- a/test/parallel/test-fs-truncate.js
+++ b/test/parallel/test-fs-truncate.js
@@ -146,3 +146,14 @@ function testFtruncate(cb) {
assert(fs.readFileSync(file4).equals(Buffer.from('Hi\u0000\u0000')));
}));
}
+
+{
+ const file5 = path.resolve(tmp, 'truncate-file-5.txt');
+ fs.writeFileSync(file5, 'Hi');
+ const fd = fs.openSync(file5, 'r+');
+ process.on('exit', () => fs.closeSync(fd));
+ fs.ftruncate(fd, undefined, common.mustCall(function(err) {
+ assert.ifError(err);
+ assert(fs.readFileSync(file5).equals(Buffer.from('')));
+ }));
+}