From 8cd2306cc3e3ea379c569ecb90f0af2afa6345e3 Mon Sep 17 00:00:00 2001 From: Richard Hong Date: Sat, 24 Sep 2016 16:14:16 -0700 Subject: [PATCH] test:replace indexOf, assert.equal, add mustCall() replace indexOf with includes replace assert.equal with assert.strictEqual add common.mustCall replace throw error with assert.ifError PR-URL: https://github.com/nodejs/node/pull/8766 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Sakthipriyan Vairamani --- test/parallel/test-fs-symlink.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js index bac0677b340393..ab52ba22923f3d 100644 --- a/test/parallel/test-fs-symlink.js +++ b/test/parallel/test-fs-symlink.js @@ -12,7 +12,7 @@ if (common.isWindows) { // On Windows, creating symlinks requires admin privileges. // We'll only try to run symlink test if we have enough privileges. exec('whoami /priv', function(err, o) { - if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) { + if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) { common.skip('insufficient privileges'); return; } @@ -25,24 +25,24 @@ common.refreshTmpDir(); const linkData = path.join(common.fixturesDir, '/cycles/root.js'); const linkPath = path.join(common.tmpDir, 'symlink1.js'); -fs.symlink(linkData, linkPath, function(err) { - if (err) throw err; +fs.symlink(linkData, linkPath, common.mustCall(function(err) { + assert.ifError(err); fs.lstat(linkPath, common.mustCall(function(err, stats) { - if (err) throw err; + assert.ifError(err); linkTime = stats.mtime.getTime(); })); fs.stat(linkPath, common.mustCall(function(err, stats) { - if (err) throw err; + assert.ifError(err); fileTime = stats.mtime.getTime(); })); fs.readlink(linkPath, common.mustCall(function(err, destination) { - if (err) throw err; - assert.equal(destination, linkData); + assert.ifError(err); + assert.strictEqual(destination, linkData); })); -}); +})); process.on('exit', function() {