Skip to content

Commit d5e30a6

Browse files
radelmannevanlucas
authored andcommitted
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: #10176 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent be87441 commit d5e30a6

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

test/parallel/test-fs-fsync.js

+14-23
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

5-
var path = require('path');
6-
var fs = require('fs');
7-
var successes = 0;
5+
const path = require('path');
6+
const fs = require('fs');
87

9-
var file = path.join(common.fixturesDir, 'a.js');
8+
const file = path.join(common.fixturesDir, 'a.js');
109

11-
fs.open(file, 'a', 0o777, function(err, fd) {
12-
if (err) throw err;
10+
fs.open(file, 'a', 0o777, common.mustCall(function(err, fd) {
11+
assert.ifError(err);
1312

1413
fs.fdatasyncSync(fd);
15-
successes++;
1614

1715
fs.fsyncSync(fd);
18-
successes++;
1916

20-
fs.fdatasync(fd, function(err) {
21-
if (err) throw err;
22-
successes++;
23-
fs.fsync(fd, function(err) {
24-
if (err) throw err;
25-
successes++;
26-
});
27-
});
28-
});
29-
30-
process.on('exit', function() {
31-
assert.equal(4, successes);
32-
});
17+
fs.fdatasync(fd, common.mustCall(function(err) {
18+
assert.ifError(err);
19+
fs.fsync(fd, common.mustCall(function(err) {
20+
assert.ifError(err);
21+
}));
22+
}));
23+
}));

0 commit comments

Comments
 (0)