0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-fs-link.js
Myles Borins 8250bfd1e5
fs: Revert throw on invalid callbacks
This reverts 4cb5f3daa3

Based on community feedback I think we should consider reverting this
change. We should explore how this could be solved via linting rules.

Refs: https://github.com/nodejs/node/pull/12562
PR-URL: https://github.com/nodejs/node/pull/12976
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-05-20 10:21:34 -04:00

37 lines
784 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
common.refreshTmpDir();
// test creating and reading hard link
const srcPath = path.join(common.tmpDir, 'hardlink-target.txt');
const dstPath = path.join(common.tmpDir, 'link1.js');
fs.writeFileSync(srcPath, 'hello world');
function callback(err) {
assert.ifError(err);
const dstContent = fs.readFileSync(dstPath, 'utf8');
assert.strictEqual('hello world', dstContent);
}
fs.link(srcPath, dstPath, common.mustCall(callback));
// test error outputs
assert.throws(
function() {
fs.link();
},
/src must be a string or Buffer/
);
assert.throws(
function() {
fs.link('abc');
},
/dest must be a string or Buffer/
);