Skip to content

Commit

Permalink
test: use mustSucceed instead of mustCall with assert.ifError
Browse files Browse the repository at this point in the history
PR-URL: #43188
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
  • Loading branch information
fossamagna authored and bengl committed May 30, 2022
1 parent 8f5b457 commit d7ca223
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions test/parallel/test-fs-options-immutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ const common = require('../common');
//
// Refer: https://github.com/nodejs/node/issues/7655

const assert = require('assert');
const fs = require('fs');
const path = require('path');

const errHandler = (e) => assert.ifError(e);
const options = Object.freeze({});
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

fs.readFile(__filename, options, common.mustCall(errHandler));
fs.readFile(__filename, options, common.mustSucceed());
fs.readFileSync(__filename, options);

fs.readdir(__dirname, options, common.mustCall(errHandler));
fs.readdir(__dirname, options, common.mustSucceed());
fs.readdirSync(__dirname, options);

if (common.canCreateSymLink()) {
Expand All @@ -28,20 +26,20 @@ if (common.canCreateSymLink()) {
fs.writeFileSync(sourceFile, '');
fs.symlinkSync(sourceFile, linkFile);

fs.readlink(linkFile, options, common.mustCall(errHandler));
fs.readlink(linkFile, options, common.mustSucceed());
fs.readlinkSync(linkFile, options);
}

{
const fileName = path.resolve(tmpdir.path, 'writeFile');
fs.writeFileSync(fileName, 'ABCD', options);
fs.writeFile(fileName, 'ABCD', options, common.mustCall(errHandler));
fs.writeFile(fileName, 'ABCD', options, common.mustSucceed());
}

{
const fileName = path.resolve(tmpdir.path, 'appendFile');
fs.appendFileSync(fileName, 'ABCD', options);
fs.appendFile(fileName, 'ABCD', options, common.mustCall(errHandler));
fs.appendFile(fileName, 'ABCD', options, common.mustSucceed());
}

if (!common.isIBMi) { // IBMi does not support fs.watch()
Expand All @@ -56,13 +54,13 @@ if (!common.isIBMi) { // IBMi does not support fs.watch()

{
fs.realpathSync(__filename, options);
fs.realpath(__filename, options, common.mustCall(errHandler));
fs.realpath(__filename, options, common.mustSucceed());
}

{
const tempFileName = path.resolve(tmpdir.path, 'mkdtemp-');
fs.mkdtempSync(tempFileName, options);
fs.mkdtemp(tempFileName, options, common.mustCall(errHandler));
fs.mkdtemp(tempFileName, options, common.mustSucceed());
}

{
Expand Down

0 comments on commit d7ca223

Please sign in to comment.