Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified the test by using common.mustCall(). Use of common.mustCal… #10040

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions test/parallel/test-fs-fsync.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');

var path = require('path');
var fs = require('fs');
var successes = 0;
const path = require('path');
const fs = require('fs');

var file = path.join(common.fixturesDir, 'a.js');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be const as well.


fs.open(file, 'a', 0o777, function(err, fd) {
fs.open(file, 'a', 0o777, common.mustCall(function(err, fd) {
if (err) throw err;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please make this assert.ifError(err).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you could change the other occurrences of if (err) throw err; as well.


fs.fdatasyncSync(fd);
successes++;

fs.fsyncSync(fd);
successes++;

fs.fdatasync(fd, function(err) {
fs.fdatasync(fd, common.mustCall(function(err) {
if (err) throw err;
successes++;
fs.fsync(fd, function(err) {
fs.fsync(fd, common.mustCall(function(err) {
if (err) throw err;
successes++;
});
});
});

process.on('exit', function() {
assert.equal(4, successes);
});
}));
}));
}));