var fs = require('fs'),
    testResource = require('../../../test_resource'),
    relativeSymlink = require('../../../../lib/file/relative_symlink');


exports['Create a relative symbolic link.'] = function (test) {
    testResource.prepareCleanWorkDirForTestFile(__filename, function (err, workDir) {
        var linkname = testResource.resolveWorkFile(workDir, 'symlink01');
        relativeSymlink(__filename, linkname, function (err) {
            test.ifError(err);
            fs.exists(linkname, function (exists) {
                test.ok(exists);
                relativeSymlink(__filename, linkname, function (err) {
                    test.ifError(err);
                    test.done();
                });
            });
        });
    });
};

exports['Handle error.'] = function (test) {
    relativeSymlink(null, null, function (err) {
        test.ok(err);
        test.done();
    });
};