Make server_option a callable function, to reduce globals

Updates acceptance test for #152 to not mess wit internals
This commit is contained in:
Sandro Santilli
2014-02-19 06:45:29 +01:00
parent 3c09be64ce
commit 1c3734fde7
6 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ log4js.configure({
// Include cartodb_windshaft only _after_ the "global" variable is set
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/28
var CartodbWindshaft = require('./lib/cartodb/cartodb_windshaft');
var serverOptions = require('./lib/cartodb/server_options');
var serverOptions = require('./lib/cartodb/server_options')();
ws = CartodbWindshaft(serverOptions);
+1 -1
View File
@@ -793,4 +793,4 @@ module.exports = function(){
};
return me;
}();
};
+6 -5
View File
@@ -15,7 +15,8 @@ require(__dirname + '/../support/test_helper');
var windshaft_fixtures = __dirname + '/../../node_modules/windshaft/test/fixtures';
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var ServerOptions = require(__dirname + '/../../lib/cartodb/server_options');
serverOptions = ServerOptions();
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
@@ -726,7 +727,7 @@ suite('multilayer', function() {
// Check X-Cache-Channel
var cc = res.headers['x-cache-channel'];
assert.ok(cc);
assert.ok(cc, "Missing X-Cache-Channel");
var dbname = 'test_cartodb_user_1_db'
assert.equal(cc.substring(0, dbname.length), dbname);
return null;
@@ -734,8 +735,8 @@ suite('multilayer', function() {
function do_restart_server(err, res) {
if ( err ) throw err;
// hack simulating restart...
assert.equal(typeof(serverOptions.channelCache), 'object');
serverOptions.channelCache = [];
serverOptions = ServerOptions();
server = new CartodbWindshaft(serverOptions);
return null;
},
function do_get1(err)
@@ -756,7 +757,7 @@ suite('multilayer', function() {
// Check X-Cache-Channel
var cc = res.headers['x-cache-channel'];
assert.ok(cc);
assert.ok(cc, "Missing X-Cache-Channel on restart");
var dbname = 'test_cartodb_user_1_db'
assert.equal(cc.substring(0, dbname.length), dbname);
return null;
+1 -1
View File
@@ -12,7 +12,7 @@ var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js');
var helper = require(__dirname + '/../support/test_helper');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')();
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
+1 -1
View File
@@ -15,7 +15,7 @@ require(__dirname + '/../support/test_helper');
var windshaft_fixtures = __dirname + '/../../node_modules/windshaft/test/fixtures';
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')();
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
+1 -1
View File
@@ -7,7 +7,7 @@ var assert = require('assert')
suite('req2params', function() {
// configure redis pool instance to use in tests
var opts = require('../../../lib/cartodb/server_options');
var opts = require('../../../lib/cartodb/server_options')();
test('can be found in server_options', function(){
assert.ok(_.isFunction(opts.req2params));