mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 21:35:34 +00:00

This adds an ESLint rule to enforce the use of `assert.ifError(err)` instead of `if (err) throw err;` in tests. PR-URL: https://github.com/nodejs/node/pull/10671 Ref: https://github.com/nodejs/node/pull/10543 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Michal Zasso <targos@protonmail.com>
35 lines
987 B
JavaScript
35 lines
987 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
// test creating and reading symbolic link
|
|
const linkData = path.join(common.fixturesDir, 'cycles/');
|
|
const linkPath = path.join(common.tmpDir, 'cycles_link');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
console.log('linkData: ' + linkData);
|
|
console.log('linkPath: ' + linkPath);
|
|
|
|
fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) {
|
|
assert.ifError(err);
|
|
|
|
fs.lstat(linkPath, common.mustCall(function(err, stats) {
|
|
assert.ifError(err);
|
|
assert.ok(stats.isSymbolicLink());
|
|
|
|
fs.readlink(linkPath, common.mustCall(function(err, destination) {
|
|
assert.ifError(err);
|
|
assert.strictEqual(destination, linkData);
|
|
|
|
fs.unlink(linkPath, common.mustCall(function(err) {
|
|
assert.ifError(err);
|
|
assert(!common.fileExists(linkPath));
|
|
assert(common.fileExists(linkData));
|
|
}));
|
|
}));
|
|
}));
|
|
}));
|