blob: 84d6c066213f28ad66d669ec59c0e403a703cb62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
var completed = 0;
var expected_tests = 4;
// test creating and reading symbolic link
var linkData = path.join(common.fixturesDir, 'cycles/');
var linkPath = path.join(common.tmpDir, 'cycles_link');
// Delete previously created link
try {
fs.unlinkSync(linkPath);
} catch (e) {}
console.log('linkData: ' + linkData);
console.log('linkPath: ' + linkPath);
fs.symlink(linkData, linkPath, 'junction', function(err) {
if (err) throw err;
completed++;
fs.lstat(linkPath, function(err, stats) {
if (err) throw err;
assert.ok(stats.isSymbolicLink());
completed++;
fs.readlink(linkPath, function(err, destination) {
if (err) throw err;
assert.equal(destination, linkData);
completed++;
fs.unlink(linkPath, function(err) {
if (err) throw err;
assert(!common.fileExists(linkPath));
assert(common.fileExists(linkData));
completed++;
});
});
});
});
process.on('exit', function() {
assert.equal(completed, expected_tests);
});
|