Skip to content

Commit

Permalink
fix tests for ftruncate
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorHalfeld committed Dec 11, 2020
1 parent ffb1861 commit e04fd9b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/parallel/test-fs-truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,14 @@ function testFtruncate(cb) {
}

{
const file6 = path.resolve(tmp, 'truncate-file-6.txt');
fs.writeFileSync(file6, 'Hi');
const fd = fs.openSync(file6, 'r+');
process.on('beforeExit', () => fs.closeSync(fd));
fs.ftruncate(fd, -1, common.mustSucceed(() => {
assert(fs.readFileSync(file6).equals(Buffer.from('')));
}));
assert.throws(
() => fs.ftruncate(fd, -1),
{
code: 'ERR_INVALID_ARG_VALUE',
name: /(TypeError|RangeError)/,
message: 'The argument \'len\' is invalid. Received -1'
}
);
}

{
Expand Down

0 comments on commit e04fd9b

Please sign in to comment.