mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
784 B
36 lines
784 B
'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/
|
|
);
|
|
|