Skip to content

Commit

Permalink
test: refactor test-fs-fsync
Browse files Browse the repository at this point in the history
- replace var with const.
- remove successes var.
- use assert.ifError() for handling all errors.
- wrap all callbacks with common.mustCall().

PR-URL: #10176
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
radelmann authored and italoacasas committed Dec 13, 2016
1 parent 3d353c7 commit 34991be
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions test/parallel/test-fs-fsync.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

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');
const file = path.join(common.fixturesDir, 'a.js');

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

fs.fdatasyncSync(fd);
successes++;

fs.fsyncSync(fd);
successes++;

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

process.on('exit', function() {
assert.equal(4, successes);
});
fs.fdatasync(fd, common.mustCall(function(err) {
assert.ifError(err);
fs.fsync(fd, common.mustCall(function(err) {
assert.ifError(err);
}));
}));
}));

0 comments on commit 34991be

Please sign in to comment.