Remove redis keys being used in tests

This commit is contained in:
Raul Ochoa 2015-09-25 14:20:21 +02:00
parent 1258466529
commit e667da8453

View File

@ -5,6 +5,8 @@ var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var LayergroupToken = require('../../lib/cartodb/models/layergroup_token');
var RedisPool = require('redis-mpool');
var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js');
@ -95,7 +97,19 @@ describe('named_layers', function() {
}
};
before(function(done) {
var keysToDelete;
beforeEach(function() {
keysToDelete = {
'user:localhost:mapviews:global': 5
};
});
afterEach(function(done) {
test_helper.deleteRedisKeys(keysToDelete, done);
});
beforeEach(function(done) {
global.environment.enabledFeatures = {cdbQueryTablesFromPostgres: true};
templateMaps.addTemplate(username, nestedNamedMapTemplate, function(err) {
if (err) {
@ -112,6 +126,23 @@ describe('named_layers', function() {
});
});
afterEach(function(done) {
global.environment.enabledFeatures = {cdbQueryTablesFromPostgres: false};
templateMaps.delTemplate(username, nestedNamedMapTemplateName, function(err) {
if (err) {
return done(err);
}
templateMaps.delTemplate(username, tokenAuthTemplateName, function(err) {
if (err) {
return done(err);
}
templateMaps.delTemplate(username, templateName, function(err) {
return done(err);
});
});
});
});
it('should fail for non-existing template name', function(done) {
var layergroup = {
version: '1.3.0',
@ -265,6 +296,8 @@ describe('named_layers', function() {
assert.ok(parsedBody.layergroupid);
assert.ok(parsedBody.last_updated);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
return null;
},
function finish(err) {
@ -398,6 +431,8 @@ describe('named_layers', function() {
assert.ok(parsedBody.layergroupid);
assert.ok(parsedBody.last_updated);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
return parsedBody.layergroupid;
},
function requestTile(err, layergroupId) {
@ -526,6 +561,8 @@ describe('named_layers', function() {
assert.ok(parsedBody.layergroupid);
assert.ok(parsedBody.last_updated);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
return parsedBody.layergroupid;
},
function requestTile(err, layergroupId) {
@ -707,6 +744,8 @@ describe('named_layers', function() {
assert.equal(parsedBody.metadata.layers[3].type, 'mapnik');
assert.equal(parsedBody.metadata.layers[4].type, 'torque');
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
return null;
},
function finish(err) {
@ -716,7 +755,6 @@ describe('named_layers', function() {
});
it('should work with named tiles', function(done) {
var namedTilesTemplateName = 'named_tiles_template';
@ -780,6 +818,8 @@ describe('named_layers', function() {
assert.equal(parsedBody.metadata.layers[0].type, 'mapnik');
assert.equal(parsedBody.metadata.layers[1].type, 'mapnik');
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
return parsedBody.layergroupid;
},
function requestTile(err, layergroupId) {
@ -828,21 +868,4 @@ describe('named_layers', function() {
);
});
after(function(done) {
global.environment.enabledFeatures = {cdbQueryTablesFromPostgres: false};
templateMaps.delTemplate(username, nestedNamedMapTemplateName, function(err) {
if (err) {
return done(err);
}
templateMaps.delTemplate(username, tokenAuthTemplateName, function(err) {
if (err) {
return done(err);
}
templateMaps.delTemplate(username, templateName, function(err) {
return done(err);
});
});
});
});
});