/** @overview nodeunit test case. */

var testResource = require('../../../test_resource'),
    fs = require('fs'),
    cleanDirectory = require('../../../../ci/worker/clean_directory.js');

exports.setUp = function (done) {
    done();
};

exports.tearDown = function (done) {
    done();
};


exports['Clean directory.'] = function (test) {
    testResource.prepareCleanWorkDirForTestFile(__filename, function (err, workDir) {
        fs.mkdir(workDir + '/bar', function () {
            fs.mkdir(workDir + '/baz', function () {
                fs.writeFile(workDir + '/baz/quz.txt', 'foo', function () {
                    cleanDirectory({
                        dir: [workDir + '/*']
                    }, function (err) {
                        test.ifError(err);
                        test.done();
                    });
                });
            });
        });
    });
};

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