Browse Source

test: refactor test-fs-fsync

- replace var with const.
- remove successes var.
- use assert.ifError() for handling all errors.
- wrap all callbacks with common.mustCall().

PR-URL: https://github.com/nodejs/node/pull/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>
v6.x
Rob Adelmann 8 years ago
committed by Myles Borins
parent
commit
217e2c6fcf
  1. 37
      test/parallel/test-fs-fsync.js

37
test/parallel/test-fs-fsync.js

@ -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);
}));
}));
}));

Loading…
Cancel
Save