From 532415f787007122321bc047c9a7c41e91ab6b2b Mon Sep 17 00:00:00 2001 From: Rob Adelmann Date: Tue, 6 Dec 2016 17:04:22 -0800 Subject: [PATCH] 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 Reviewed-By: Santiago Gimeno Reviewed-By: Italo A. Casas Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-fs-fsync.js | 37 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/test/parallel/test-fs-fsync.js b/test/parallel/test-fs-fsync.js index 89d104c00246bc..f69a3c5e7f13c6 100644 --- a/test/parallel/test-fs-fsync.js +++ b/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); + })); + })); +}));