Skip to content

Commit b0990ef

Browse files
committed
test: confirm symlink
PR-URL: #2014 Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 3ba4f71 commit b0990ef

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/parallel/test-fs-symlink.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ var path = require('path');
55
var fs = require('fs');
66
var exec = require('child_process').exec;
77
var completed = 0;
8-
var expected_tests = 2;
8+
var expected_async = 4;
9+
var linkTime;
10+
var fileTime;
911

1012
var is_windows = process.platform === 'win32';
1113

@@ -20,7 +22,19 @@ var runtest = function(skip_symlinks) {
2022
fs.symlink(linkData, linkPath, function(err) {
2123
if (err) throw err;
2224
console.log('symlink done');
23-
// todo: fs.lstat?
25+
26+
fs.lstat(linkPath, function(err, stats) {
27+
if (err) throw err;
28+
linkTime = stats.mtime.getTime();
29+
completed++;
30+
});
31+
32+
fs.stat(linkPath, function(err, stats) {
33+
if (err) throw err;
34+
fileTime = stats.mtime.getTime();
35+
completed++;
36+
});
37+
2438
fs.readlink(linkPath, function(err, destination) {
2539
if (err) throw err;
2640
assert.equal(destination, linkData);
@@ -48,7 +62,7 @@ if (is_windows) {
4862
// We'll only try to run symlink test if we have enough privileges.
4963
exec('whoami /priv', function(err, o) {
5064
if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) {
51-
expected_tests = 1;
65+
expected_async = 1;
5266
runtest(true);
5367
} else {
5468
runtest(false);
@@ -59,6 +73,7 @@ if (is_windows) {
5973
}
6074

6175
process.on('exit', function() {
62-
assert.equal(completed, expected_tests);
76+
assert.equal(completed, expected_async);
77+
assert(linkTime !== fileTime);
6378
});
6479

0 commit comments

Comments
 (0)