Create application server inside of describes instead of at module level

This commit is contained in:
Daniel García Aubert 2018-04-16 14:09:24 +02:00
parent 09fdf5b990
commit 98f29f945b
18 changed files with 36 additions and 27 deletions

View File

@ -4,12 +4,12 @@ var helper = require('../../support/test_helper');
var CartodbWindshaft = require('../../../lib/cartodb/server');
var serverOptions = require('../../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var TestClient = require('../../support/test-client');
var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token');
describe('named-maps analysis', function() {
var server = new CartodbWindshaft(serverOptions);
var IMAGE_TOLERANCE_PER_MIL = 20;

View File

@ -5,7 +5,6 @@ const assert = require('../../support/assert');
const testHelper = require('../../support/test_helper');
const CartodbWindshaft = require('../../../lib/cartodb/server');
const serverOptions = require('../../../lib/cartodb/server_options');
const server = new CartodbWindshaft(serverOptions);
var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token');
function singleLayergroupConfig(sql, cartocss) {
@ -46,6 +45,8 @@ var pointSqlPublic = "select * from test_table";
var keysToDelete;
describe('authorization fallback', function () {
const server = new CartodbWindshaft(serverOptions);
beforeEach(function () {
keysToDelete = {};
});
@ -56,7 +57,7 @@ describe('authorization fallback', function () {
it("succeed with master", function (done) {
var layergroup = singleLayergroupConfig(pointSqlMaster, '#layer { marker-fill:red; }');
assert.response(server,
createRequest(layergroup, 'user_previous_to_project_auth', '4444'),
{

View File

@ -5,12 +5,12 @@ var qs = require('querystring');
var CartodbWindshaft = require('../../../lib/cartodb/server');
var serverOptions = require('../../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token');
describe('get requests with cache headers', function() {
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
var keysToDelete;
beforeEach(function() {

View File

@ -4,9 +4,9 @@ var LayergroupToken = require('../../lib/cartodb/models/layergroup-token');
var testHelper = require(__dirname + '/../support/test_helper');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
describe('dynamic styling for named maps', function() {
var server = new CartodbWindshaft(serverOptions);
var keysToDelete;

View File

@ -1,9 +1,10 @@
var assert = require('../support/assert');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
describe('error with context', function () {
var server = new CartodbWindshaft(serverOptions);
var layerOK = {
options: {
sql: 'select cartodb_id, ST_Translate(the_geom_webmercator, 5e6, 0) as the_geom_webmercator ' +

View File

@ -18,8 +18,6 @@ var IMAGE_EQUALS_HIGHER_TOLERANCE_PER_MIL = 25;
var CartodbWindshaft = require('../../lib/cartodb/server');
var serverOptions = require('../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
var QueryTables = require('cartodb-query-tables');
@ -27,7 +25,8 @@ var QueryTables = require('cartodb-query-tables');
var suiteName = 'multilayer:postgres=layergroup_url=' + layergroup_url;
describe(suiteName, function() {
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
var keysToDelete;

View File

@ -10,10 +10,10 @@ var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner');
var QueryTables = require('cartodb-query-tables');
var CartodbWindshaft = require('../../lib/cartodb/server');
var serverOptions = require('../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
describe('tests from old api translated to multilayer', function() {
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
var layergroupUrl = '/api/v1/map';

View File

@ -3,7 +3,6 @@ var test_helper = require('../support/test_helper');
var assert = require('../support/assert');
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');
@ -13,6 +12,8 @@ var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js');
var step = require('step');
describe('named_layers', function() {
var server = new CartodbWindshaft(serverOptions);
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);

View File

@ -4,7 +4,6 @@ var test_helper = require('../support/test_helper');
var assert = require('../support/assert');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var RedisPool = require('redis-mpool');
var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js');
@ -13,6 +12,7 @@ var mapnik = require('windshaft').mapnik;
var IMAGE_TOLERANCE = 20;
describe('layers visibility for previews', function() {
var server = new CartodbWindshaft(serverOptions);
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);
var templateMaps = new TemplateMaps(redisPool, {

View File

@ -6,11 +6,12 @@ var assert = require('../support/assert');
var mapnik = require('windshaft').mapnik;
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js');
var NamedMapsCacheEntry = require('../../lib/cartodb/cache/model/named_maps_entry');
describe('named maps authentication', function() {
var server = new CartodbWindshaft(serverOptions);
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);

View File

@ -5,10 +5,11 @@ var assert = require('../support/assert');
var mapnik = require('windshaft').mapnik;
var CartodbWindshaft = require('../../lib/cartodb/server');
var serverOptions = require('../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js');
describe('named maps provider cache', function() {
var server = new CartodbWindshaft(serverOptions);
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);

View File

@ -6,11 +6,12 @@ var assert = require('../support/assert');
var mapnik = require('windshaft').mapnik;
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js');
var NamedMapsCacheEntry = require('../../lib/cartodb/cache/model/named_maps_entry');
describe('named maps preview stats', function() {
var server = new CartodbWindshaft(serverOptions);
var redisPool = new RedisPool(global.environment.redis);
var templateMaps = new TemplateMaps(redisPool, {

View File

@ -3,7 +3,6 @@ var test_helper = require('../support/test_helper');
var assert = require('../support/assert');
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');
@ -15,6 +14,8 @@ var windshaft = require('windshaft');
describe('overviews metadata', function() {
var server = new CartodbWindshaft(serverOptions);
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);
@ -111,6 +112,8 @@ describe('overviews metadata', function() {
});
describe('overviews metadata with filters', function() {
var server = new CartodbWindshaft(serverOptions);
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);

View File

@ -3,7 +3,6 @@ var test_helper = require('../support/test_helper');
var assert = require('../support/assert');
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');
@ -13,8 +12,9 @@ var step = require('step');
var windshaft = require('windshaft');
describe('overviews metadata for named maps', function() {
var server = new CartodbWindshaft(serverOptions);
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);

View File

@ -6,11 +6,11 @@ var step = require('step');
var CartodbWindshaft = require('../../lib/cartodb/server');
var serverOptions = require('../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
describe('server', function() {
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
// TODO: I guess this should be a 404 instead...
it("get call to server returns 200", function(done){
@ -54,6 +54,8 @@ describe('server', function() {
});
describe('server old_api', function() {
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
// See https://github.com/CartoDB/Windshaft-cartodb/issues/115
it.skip("get'ing tile with not-strictly-valid style", function(done) {
@ -68,5 +70,4 @@ describe('server old_api', function() {
done();
});
});
});

View File

@ -20,12 +20,12 @@ var helper = require(__dirname + '/../support/test_helper');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
var LayergroupToken = require('../../lib/cartodb/models/layergroup-token');
describe('template_api', function() {
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
server.layergroupAffectedTablesCache.cache.reset();
var httpRendererResourcesServer;

View File

@ -4,11 +4,11 @@ var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token');
var testHelper = require('../../support/test_helper');
var CartodbWindshaft = require('../../../lib/cartodb/server');
var serverOptions = require('../../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var mapnik = require('windshaft').mapnik;
var IMAGE_TOLERANCE_PER_MIL = 10;
describe('turbo-carto for named maps', function() {
var server = new CartodbWindshaft(serverOptions);
var keysToDelete;

View File

@ -8,11 +8,11 @@ var helper = require('../../support/test_helper');
var CartodbWindshaft = require('../../../lib/cartodb/server');
var serverOptions = require('../../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var LayergroupToken = require('../../../lib/cartodb/models/layergroup-token');
describe('named-maps widgets', function() {
var server = new CartodbWindshaft(serverOptions);
var username = 'localhost';
var widgetsTemplateName = 'widgets-template';