/** @overview nodeunit test case. */

var testResource = require('../../../test_resource'),
    mockInjector = require('../../../mock_injector'),
    executeTravisEncrypt = require('../../../../task/worker/execute_travis_encrypt.js');

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

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


exports['Execute travis encrypt.'] = function (test) {
    mockInjector.inject(executeTravisEncrypt, '_execute', function (c, callback) {
        callback(null, 'foo');
    });
    executeTravisEncrypt({
        secretFile: testResource.resolveMockFile('mock-data.json')
    }, function (err) {
        mockInjector.restore();
        test.ifError(err);
        test.done();
    });
};
exports['Handle error.'] = function (test) {

    mockInjector.inject(executeTravisEncrypt, '_execute', function (c, callback) {
        callback(null, '');
    });
    executeTravisEncrypt({
        secretFile: testResource.resolveMockFile('mock-data.json')
    }, function (err) {
        mockInjector.restore();
        test.ok(err);
        test.done();
    });
};