Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fs.link() on same device #4859

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/parallel/test-fs-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ common.refreshTmpDir();

// test creating and reading hard link
const srcPath = path.join(common.fixturesDir, 'cycles', 'root.js');
const tmpSrcPath = path.join(common.tmpDir, 'root.js');
const dstPath = path.join(common.tmpDir, 'link1.js');
const srcContent = fs.readFileSync(srcPath, 'utf8');

const callback = function(err) {
if (err) throw err;
const srcContent = fs.readFileSync(srcPath, 'utf8');
const dstContent = fs.readFileSync(dstPath, 'utf8');
assert.strictEqual(srcContent, dstContent);
};

fs.link(srcPath, dstPath, common.mustCall(callback));
// copy to same directory to avoid cross-filesystem issues
fs.writeFileSync(tmpSrcPath, srcContent, 'utf8');
fs.link(tmpSrcPath, dstPath, common.mustCall(callback));