/** @overview nodeunit test case. */

var testResource = require('../../../test_resource'),
    mockInjector = require('../../../mock_injector'),
    fs = require('fs'),
    cutAndReplaceLinks = require('../../../../ci/worker/cut_and_replace_links.js');

exports.setUp = function (done) {
    process.env.CI_LOG_DISABLED = true;
    done();
};

exports.tearDown = function (done) {
    process.env.CI_LOG_DISABLED = false;
    mockInjector.restoreAll();
    done();
};


exports['Cut and replace links.'] = function (test) {
    testResource.prepareCleanWorkDirForTestFile(__filename, function (err, workDir) {
        fs.writeFile(workDir + '/work_text01.txt', 'foo', function () {
            fs.symlink(workDir + '/work_text01.txt', workDir + '/work_text02.txt', function () {
                cutAndReplaceLinks({
                    basedir: workDir
                }, function (err) {
                    test.ifError(err);
                    test.done();
                });
            });
        });
    });
};