rmdirRecursiveSync DRY
This commit is contained in:
parent
67ba424a19
commit
f33c3ce21a
@ -1,4 +1,4 @@
|
||||
require('../../support/test_helper');
|
||||
var testHelper = require('../../support/test_helper');
|
||||
|
||||
|
||||
var assert = require('../../support/assert');
|
||||
@ -11,20 +11,6 @@ var nock = require('nock');
|
||||
|
||||
var BaseController = require('../../../lib/cartodb/controllers/base');
|
||||
|
||||
function rmdir_recursive_sync(dirname) {
|
||||
var files = fs.readdirSync(dirname);
|
||||
for (var i=0; i<files.length; ++i) {
|
||||
var f = dirname + "/" + files[i];
|
||||
var s = fs.lstatSync(f);
|
||||
if ( s.isFile() ) {
|
||||
fs.unlinkSync(f);
|
||||
}
|
||||
else {
|
||||
rmdir_recursive_sync(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('external resources', function() {
|
||||
|
||||
var res_serv; // resources server
|
||||
@ -60,7 +46,7 @@ describe('external resources', function() {
|
||||
after(function(done) {
|
||||
BaseController.prototype.req2params = req2paramsFn;
|
||||
|
||||
rmdir_recursive_sync(global.environment.millstone.cache_basedir);
|
||||
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
||||
|
||||
// Close the resources server
|
||||
res_serv.close(done);
|
||||
@ -112,7 +98,7 @@ describe('external resources', function() {
|
||||
assert.equal(res_serv_status.numrequests, externalResourceRequestsCount);
|
||||
|
||||
// reset resources cache
|
||||
rmdir_recursive_sync(global.environment.millstone.cache_basedir);
|
||||
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
||||
|
||||
externalResourceMapConfig = testClient.defaultTableMapConfig('test_table_3 ', externalResourceStyle);
|
||||
|
||||
|
@ -1,26 +1,11 @@
|
||||
require('../../support/test_helper');
|
||||
var testHelper = require('../../support/test_helper');
|
||||
|
||||
var assert = require('../../support/assert');
|
||||
var fs = require('fs');
|
||||
var ServerOptions = require('./support/ported_server_options');
|
||||
var testClient = require('./support/test_client');
|
||||
|
||||
var BaseController = require('../../../lib/cartodb/controllers/base');
|
||||
|
||||
function rmdir_recursive_sync(dirname) {
|
||||
var files = fs.readdirSync(dirname);
|
||||
for (var i=0; i<files.length; ++i) {
|
||||
var f = dirname + "/" + files[i];
|
||||
var s = fs.lstatSync(f);
|
||||
if ( s.isFile() ) {
|
||||
fs.unlinkSync(f);
|
||||
}
|
||||
else {
|
||||
rmdir_recursive_sync(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('regressions', function() {
|
||||
|
||||
var req2paramsFn;
|
||||
@ -32,7 +17,7 @@ describe('regressions', function() {
|
||||
|
||||
after(function() {
|
||||
BaseController.prototype.req2params = req2paramsFn;
|
||||
rmdir_recursive_sync(global.environment.millstone.cache_basedir);
|
||||
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
||||
});
|
||||
|
||||
// See https://github.com/Vizzuality/Windshaft/issues/65
|
||||
|
@ -1,26 +1,12 @@
|
||||
require('../../support/test_helper');
|
||||
var testHelper = require('../../support/test_helper');
|
||||
|
||||
var assert = require('../../support/assert');
|
||||
var fs = require('fs');
|
||||
var cartodbServer = require('../../../lib/cartodb/server');
|
||||
var ServerOptions = require('./support/ported_server_options');
|
||||
var testClient = require('./support/test_client');
|
||||
|
||||
var BaseController = require('../../../lib/cartodb/controllers/base');
|
||||
|
||||
function rmdir_recursive_sync(dirname) {
|
||||
var files = fs.readdirSync(dirname);
|
||||
for (var i=0; i<files.length; ++i) {
|
||||
var f = dirname + "/" + files[i];
|
||||
var s = fs.lstatSync(f);
|
||||
if ( s.isFile() ) {
|
||||
fs.unlinkSync(f);
|
||||
} else {
|
||||
rmdir_recursive_sync(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('server', function() {
|
||||
|
||||
var server = cartodbServer(ServerOptions);
|
||||
@ -35,7 +21,7 @@ describe('server', function() {
|
||||
after(function() {
|
||||
BaseController.prototype.req2params = req2paramsFn;
|
||||
|
||||
rmdir_recursive_sync(global.environment.millstone.cache_basedir);
|
||||
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,7 +1,6 @@
|
||||
require('../../support/test_helper');
|
||||
var testHelper = require('../../support/test_helper');
|
||||
|
||||
var assert = require('../../support/assert');
|
||||
var fs = require('fs');
|
||||
var mapnik = require('windshaft').mapnik;
|
||||
var semver = require('semver');
|
||||
var cartodbServer = require('../../../lib/cartodb/server');
|
||||
@ -10,20 +9,6 @@ var testClient = require('./support/test_client');
|
||||
|
||||
var BaseController = require('../../../lib/cartodb/controllers/base');
|
||||
|
||||
function rmdir_recursive_sync(dirname) {
|
||||
var files = fs.readdirSync(dirname);
|
||||
for (var i=0; i<files.length; ++i) {
|
||||
var f = dirname + "/" + files[i];
|
||||
var s = fs.lstatSync(f);
|
||||
if ( s.isFile() ) {
|
||||
fs.unlinkSync(f);
|
||||
}
|
||||
else {
|
||||
rmdir_recursive_sync(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('server_gettile', function() {
|
||||
|
||||
var server = cartodbServer(ServerOptions);
|
||||
@ -41,7 +26,7 @@ describe('server_gettile', function() {
|
||||
after(function() {
|
||||
BaseController.prototype.req2params = req2paramsFn;
|
||||
|
||||
rmdir_recursive_sync(global.environment.millstone.cache_basedir);
|
||||
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
||||
});
|
||||
|
||||
function imageCompareFn(fixture, done) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var LZMA = require('lzma').LZMA;
|
||||
|
||||
var lzmaWorker = new LZMA();
|
||||
@ -135,12 +136,26 @@ function deleteRedisKeys(keysToDelete, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function rmdirRecursiveSync(dirname) {
|
||||
var files = fs.readdirSync(dirname);
|
||||
for (var i=0; i<files.length; ++i) {
|
||||
var f = dirname + "/" + files[i];
|
||||
var s = fs.lstatSync(f);
|
||||
if ( s.isFile() ) {
|
||||
fs.unlinkSync(f);
|
||||
}
|
||||
else {
|
||||
rmdirRecursiveSync(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
deleteRedisKeys: deleteRedisKeys,
|
||||
lzma_compress_to_base64: lzma_compress_to_base64,
|
||||
checkNoCache: checkNoCache,
|
||||
checkSurrogateKey: checkSurrogateKey,
|
||||
checkCache: checkCache
|
||||
checkCache: checkCache,
|
||||
rmdirRecursiveSync: rmdirRecursiveSync
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user