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 <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
7f7502d901
commit
8cd2306cc3
@ -12,7 +12,7 @@ if (common.isWindows) {
|
|||||||
// On Windows, creating symlinks requires admin privileges.
|
// On Windows, creating symlinks requires admin privileges.
|
||||||
// We'll only try to run symlink test if we have enough privileges.
|
// We'll only try to run symlink test if we have enough privileges.
|
||||||
exec('whoami /priv', function(err, o) {
|
exec('whoami /priv', function(err, o) {
|
||||||
if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) {
|
if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) {
|
||||||
common.skip('insufficient privileges');
|
common.skip('insufficient privileges');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -25,24 +25,24 @@ common.refreshTmpDir();
|
|||||||
const linkData = path.join(common.fixturesDir, '/cycles/root.js');
|
const linkData = path.join(common.fixturesDir, '/cycles/root.js');
|
||||||
const linkPath = path.join(common.tmpDir, 'symlink1.js');
|
const linkPath = path.join(common.tmpDir, 'symlink1.js');
|
||||||
|
|
||||||
fs.symlink(linkData, linkPath, function(err) {
|
fs.symlink(linkData, linkPath, common.mustCall(function(err) {
|
||||||
if (err) throw err;
|
assert.ifError(err);
|
||||||
|
|
||||||
fs.lstat(linkPath, common.mustCall(function(err, stats) {
|
fs.lstat(linkPath, common.mustCall(function(err, stats) {
|
||||||
if (err) throw err;
|
assert.ifError(err);
|
||||||
linkTime = stats.mtime.getTime();
|
linkTime = stats.mtime.getTime();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fs.stat(linkPath, common.mustCall(function(err, stats) {
|
fs.stat(linkPath, common.mustCall(function(err, stats) {
|
||||||
if (err) throw err;
|
assert.ifError(err);
|
||||||
fileTime = stats.mtime.getTime();
|
fileTime = stats.mtime.getTime();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fs.readlink(linkPath, common.mustCall(function(err, destination) {
|
fs.readlink(linkPath, common.mustCall(function(err, destination) {
|
||||||
if (err) throw err;
|
assert.ifError(err);
|
||||||
assert.equal(destination, linkData);
|
assert.strictEqual(destination, linkData);
|
||||||
}));
|
}));
|
||||||
});
|
}));
|
||||||
|
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user