var fs = require('fs'),
    path = require('path'),
    mockInjector = require('../../../mock_injector'),
    testResource = require('../../../test_resource'),
    changeMode = require('../../../../ci/worker/change_mode');

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


exports['Change file mode'] = function (test) {
    var filename = testResource.resolveWorkFile('work_task_change_mode.txt');
    fs.writeFile(filename, 'foo', function () {
        changeMode({
            pattern: path.dirname(filename) + '/*.txt',
            mode: '755'
        }, function (err) {
            test.ifError(err);
            test.done();
        });
    });
};

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