Rename factory and don't use the keyword 'new' to create server while testing
This commit is contained in:
parent
48c28aea0b
commit
ffe19827fd
@ -4,7 +4,7 @@ var assert = require('../../support/assert');
|
||||
|
||||
var helper = require('../../support/test-helper');
|
||||
|
||||
var CartodbWindshaft = require('../../../lib/server');
|
||||
const createServer = require('../../../lib/server');
|
||||
var serverOptions = require('../../../lib/server-options');
|
||||
var TestClient = require('../../support/test-client');
|
||||
|
||||
@ -14,7 +14,7 @@ describe('named-maps analysis', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
var IMAGE_TOLERANCE_PER_MIL = 20;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
const assert = require('../../support/assert');
|
||||
const testHelper = require('../../support/test-helper');
|
||||
const CartodbWindshaft = require('../../../lib/server');
|
||||
const createServer = require('../../../lib/server');
|
||||
const serverOptions = require('../../../lib/server-options');
|
||||
var LayergroupToken = require('../../../lib/models/layergroup-token');
|
||||
|
||||
@ -47,7 +47,7 @@ describe('Basic authorization use cases', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
4
test/acceptance/cache/cache-headers-test.js
vendored
4
test/acceptance/cache/cache-headers-test.js
vendored
@ -5,7 +5,7 @@ var testHelper = require('../../support/test-helper');
|
||||
var assert = require('../../support/assert');
|
||||
var qs = require('querystring');
|
||||
|
||||
var CartodbWindshaft = require('../../../lib/server');
|
||||
const createServer = require('../../../lib/server');
|
||||
var serverOptions = require('../../../lib/server-options');
|
||||
|
||||
var LayergroupToken = require('../../../lib/models/layergroup-token');
|
||||
@ -14,7 +14,7 @@ describe('get requests with cache headers', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
server.setMaxListeners(0);
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@ var step = require('step');
|
||||
var FastlyPurge = require('fastly-purge');
|
||||
var _ = require('underscore');
|
||||
var NamedMapsCacheEntry = require('../../../lib/cache/model/named-maps-entry');
|
||||
var CartodbWindshaft = require('../../../lib/server');
|
||||
const createServer = require('../../../lib/server');
|
||||
var nock = require('nock');
|
||||
|
||||
describe('templates surrogate keys', function () {
|
||||
@ -33,7 +33,7 @@ describe('templates surrogate keys', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
nock.disableNetConnect();
|
||||
nock.enableNetConnect(/(127.0.0.1|cartocdn.com)/);
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ require('../support/test-helper');
|
||||
var fs = require('fs');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
describe('health checks', function () {
|
||||
@ -41,7 +41,7 @@ describe('health checks', function () {
|
||||
};
|
||||
|
||||
it('returns 200 and ok=true with enabled configuration', function (done) {
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, healthCheckRequest, RESPONSE_OK, function (res, err) {
|
||||
assert.ok(!err);
|
||||
@ -62,7 +62,7 @@ describe('health checks', function () {
|
||||
fs.readFile = function (filename, callback) {
|
||||
callback(null, errorMessage);
|
||||
};
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, healthCheckRequest, RESPONSE_FAIL, function (res, err) {
|
||||
fs.readFile = readFileFn;
|
||||
@ -82,7 +82,7 @@ describe('health checks', function () {
|
||||
fs.readFile = function (filename, callback) {
|
||||
callback(null, '');
|
||||
};
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, healthCheckRequest, RESPONSE_FAIL, function (res, err) {
|
||||
fs.readFile = readFileFn;
|
||||
@ -100,7 +100,7 @@ describe('health checks', function () {
|
||||
it('not err if disabled file does not exist', function (done) {
|
||||
global.environment.disabled_file = '/tmp/ftreftrgtrccre';
|
||||
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, healthCheckRequest, RESPONSE_OK, function (res, err) {
|
||||
assert.ok(!err);
|
||||
|
@ -10,14 +10,14 @@ var LayergroupToken = require('../../lib/models/layergroup-token');
|
||||
|
||||
var PgQueryRunner = require('../../lib/backends/pg-query-runner');
|
||||
var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
describe('tests from old api translated to multilayer', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
server.setMaxListeners(0);
|
||||
});
|
||||
|
||||
|
@ -19,7 +19,7 @@ var windshaftFixtures = path.join(__dirname, '/../../node_modules/windshaft/test
|
||||
var IMAGE_EQUALS_TOLERANCE_PER_MIL = 20;
|
||||
var IMAGE_EQUALS_HIGHER_TOLERANCE_PER_MIL = 25;
|
||||
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
@ -30,7 +30,7 @@ var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
server.setMaxListeners(0);
|
||||
});
|
||||
|
||||
@ -851,7 +851,7 @@ var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
function doRestartServer (err/*, res */) {
|
||||
assert.ifError(err);
|
||||
// hack simulating restart...
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
return null;
|
||||
},
|
||||
function doGet1 (err) {
|
||||
@ -1274,7 +1274,7 @@ var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
it('cache control for layergroup default value', function (done) {
|
||||
global.environment.varnish.layergroupTtl = null;
|
||||
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, layergroupTtlRequest, layergroupTtlResponseExpectation,
|
||||
function (res) {
|
||||
@ -1291,7 +1291,7 @@ var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
var layergroupTtl = 300;
|
||||
global.environment.varnish.layergroupTtl = layergroupTtl;
|
||||
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, layergroupTtlRequest, layergroupTtlResponseExpectation,
|
||||
function (res) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
var testHelper = require('../support/test-helper');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
var LayergroupToken = require('../../lib/models/layergroup-token');
|
||||
@ -17,7 +17,7 @@ describe('named_layers', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
// configure redis pool instance to use in tests
|
||||
|
@ -4,7 +4,7 @@ var step = require('step');
|
||||
var testHelper = require('../support/test-helper');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
var RedisPool = require('redis-mpool');
|
||||
@ -17,7 +17,7 @@ describe('layers visibility for previews', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
// configure redis pool instance to use in tests
|
||||
|
@ -6,7 +6,7 @@ var querystring = require('querystring');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
const mapnik = require('@carto/mapnik');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
var TemplateMaps = require('../../lib/backends/template-maps');
|
||||
var NamedMapsCacheEntry = require('../../lib/cache/model/named-maps-entry');
|
||||
@ -15,7 +15,7 @@ describe('named maps authentication', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
// configure redis pool instance to use in tests
|
||||
|
@ -5,14 +5,14 @@ require('../support/test-helper');
|
||||
const helper = require('../support/test-helper');
|
||||
var assert = require('../support/assert');
|
||||
const mapnik = require('@carto/mapnik');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
describe('named maps provider cache', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
var username = 'localhost';
|
||||
|
@ -6,7 +6,7 @@ var RedisPool = require('redis-mpool');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
const mapnik = require('@carto/mapnik');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
var TemplateMaps = require('../../lib/backends/template-maps');
|
||||
|
||||
@ -86,7 +86,7 @@ describe('named maps static view', function () {
|
||||
};
|
||||
|
||||
// this could be removed once named maps are invalidated, otherwise you hits the cache
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, requestOptions, expectedResponse, function (res, err) {
|
||||
testHelper.deleteRedisKeys({ 'user:localhost:mapviews:global': 5 }, function () {
|
||||
@ -323,7 +323,7 @@ describe('named maps static view', function () {
|
||||
};
|
||||
|
||||
// this could be removed once named maps are invalidated, otherwise you hits the cache
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, requestOptions, expectedResponse, function (res, err) {
|
||||
assert.ifError(err);
|
||||
|
@ -6,7 +6,7 @@ var querystring = require('querystring');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
const mapnik = require('@carto/mapnik');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
var TemplateMaps = require('../../lib/backends/template-maps');
|
||||
var NamedMapsCacheEntry = require('../../lib/cache/model/named-maps-entry');
|
||||
@ -15,7 +15,7 @@ describe('named maps preview stats', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
var redisPool = new RedisPool(global.environment.redis);
|
||||
|
@ -3,7 +3,7 @@
|
||||
var testHelper = require('../support/test-helper');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
var LayergroupToken = require('../../lib/models/layergroup-token');
|
||||
@ -18,7 +18,7 @@ describe('overviews metadata for named maps', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
// configure redis pool instance to use in tests
|
||||
|
@ -3,7 +3,7 @@
|
||||
var testHelper = require('../support/test-helper');
|
||||
|
||||
var assert = require('../support/assert');
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
var LayergroupToken = require('../../lib/models/layergroup-token');
|
||||
@ -18,7 +18,7 @@ describe('overviews metadata', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
// configure redis pool instance to use in tests
|
||||
@ -193,7 +193,7 @@ describe('overviews metadata with filters', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
// configure redis pool instance to use in tests
|
||||
|
@ -5,7 +5,7 @@ var assert = require('../support/assert');
|
||||
const helper = require('../support/test-helper');
|
||||
var TestClient = require('../support/test-client');
|
||||
const LayergroupToken = require('../../lib/models/layergroup-token');
|
||||
const CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
const serverOptions = require('../../lib/server-options');
|
||||
|
||||
describe('regressions', function () {
|
||||
@ -44,7 +44,7 @@ describe('regressions', function () {
|
||||
|
||||
// See: https://github.com/CartoDB/Windshaft-cartodb/pull/956
|
||||
it('"/user/localhost/api/v1/map" should create an anonymous map', function (done) {
|
||||
const server = new CartodbWindshaft(serverOptions);
|
||||
const server = createServer(serverOptions);
|
||||
const layergroup = {
|
||||
version: '1.7.0',
|
||||
layers: [
|
||||
|
@ -6,14 +6,14 @@ var assert = require('../support/assert');
|
||||
var querystring = require('querystring');
|
||||
var step = require('step');
|
||||
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
describe('server', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
server.setMaxListeners(0);
|
||||
});
|
||||
|
||||
@ -45,7 +45,7 @@ describe('server old_api', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
server.setMaxListeners(0);
|
||||
});
|
||||
|
||||
|
@ -21,7 +21,7 @@ var http = require('http');
|
||||
|
||||
var helper = require('../support/test-helper');
|
||||
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
|
||||
var LayergroupToken = require('../../lib/models/layergroup-token');
|
||||
@ -30,7 +30,7 @@ describe('template_api', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
server.setMaxListeners(0);
|
||||
// FIXME: we need a better way to reset cache while running tests
|
||||
server.layergroupAffectedTablesCache.cache.reset();
|
||||
|
@ -4,7 +4,7 @@ var assert = require('../../support/assert');
|
||||
var step = require('step');
|
||||
var LayergroupToken = require('../../../lib/models/layergroup-token');
|
||||
var testHelper = require('../../support/test-helper');
|
||||
var CartodbWindshaft = require('../../../lib/server');
|
||||
const createServer = require('../../../lib/server');
|
||||
var serverOptions = require('../../../lib/server-options');
|
||||
const mapnik = require('@carto/mapnik');
|
||||
var IMAGE_TOLERANCE_PER_MIL = 10;
|
||||
@ -13,7 +13,7 @@ describe('turbo-carto for named maps', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
var keysToDelete;
|
||||
|
@ -8,7 +8,7 @@ var queue = require('queue-async');
|
||||
|
||||
var helper = require('../../support/test-helper');
|
||||
|
||||
var CartodbWindshaft = require('../../../lib/server');
|
||||
const createServer = require('../../../lib/server');
|
||||
var serverOptions = require('../../../lib/server-options');
|
||||
|
||||
var LayergroupToken = require('../../../lib/models/layergroup-token');
|
||||
@ -17,7 +17,7 @@ describe('named-maps widgets', function () {
|
||||
var server;
|
||||
|
||||
before(function () {
|
||||
server = new CartodbWindshaft(serverOptions);
|
||||
server = createServer(serverOptions);
|
||||
});
|
||||
|
||||
var username = 'localhost';
|
||||
|
@ -12,7 +12,7 @@ var LayergroupToken = require('../../lib/models/layergroup-token');
|
||||
var assert = require('./assert');
|
||||
var helper = require('./test-helper');
|
||||
|
||||
var CartodbWindshaft = require('../../lib/server');
|
||||
const createServer = require('../../lib/server');
|
||||
var serverOptions = require('../../lib/server-options');
|
||||
serverOptions.analysis.batch.inlineExecution = true;
|
||||
|
||||
@ -30,7 +30,7 @@ function TestClient (config, apiKey, extraHeaders = {}, overrideServerOptions =
|
||||
this.extraHeaders = extraHeaders;
|
||||
this.keysToDelete = {};
|
||||
this.serverOptions = Object.assign({}, serverOptions, overrideServerOptions);
|
||||
this.server = new CartodbWindshaft(this.serverOptions);
|
||||
this.server = createServer(this.serverOptions);
|
||||
}
|
||||
|
||||
module.exports = TestClient;
|
||||
@ -1348,7 +1348,7 @@ TestClient.prototype.drain = function (callback) {
|
||||
module.exports.getStaticMap = function getStaticMap (templateName, params, callback) {
|
||||
var self = this;
|
||||
|
||||
self.server = new CartodbWindshaft(serverOptions);
|
||||
self.server = createServer(serverOptions);
|
||||
|
||||
if (!callback) {
|
||||
callback = params;
|
||||
@ -1378,7 +1378,7 @@ module.exports.getStaticMap = function getStaticMap (templateName, params, callb
|
||||
};
|
||||
|
||||
// this could be removed once named maps are invalidated, otherwise you hits the cache
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
var server = createServer(serverOptions);
|
||||
|
||||
assert.response(server, requestOptions, expectedResponse, function (res, err) {
|
||||
helper.deleteRedisKeys({ 'user:localhost:mapviews:global': 5 }, function () {
|
||||
|
Loading…
Reference in New Issue
Block a user