diff options
author | VinÃcius do Carmo <vinicius.m.do.carmo@gmail.com> | 2017-01-24 00:58:00 -0300 |
---|---|---|
committer | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-01-26 11:36:08 -0500 |
commit | efbda74686e51525517ec2f89b75039d1db57e59 (patch) | |
tree | 0b42afc9f0de759644f813b1bc966c1f31f71e25 /test/parallel/test-fs-truncate-sync.js | |
parent | f73bc91756373f4057b3fc139dc5968049fa8c2a (diff) | |
download | android-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-sync.js')
-rw-r--r-- | test/parallel/test-fs-truncate-sync.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/parallel/test-fs-truncate-sync.js b/test/parallel/test-fs-truncate-sync.js new file mode 100644 index 0000000000..a7ce2f4d97 --- /dev/null +++ b/test/parallel/test-fs-truncate-sync.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); +const tmp = common.tmpDir; + +common.refreshTmpDir(); + +const filename = path.resolve(tmp, 'truncate-sync-file.txt'); + +fs.writeFileSync(filename, 'hello world', 'utf8'); + +const fd = fs.openSync(filename, 'r+'); + +fs.truncateSync(fd, 5); +assert(fs.readFileSync(fd).equals(Buffer.from('hello'))); + +fs.closeSync(fd); +fs.unlinkSync(filename); |