Fix lack of response on backend crash

Closes #135
Enables previously failing test
Required upgrade of node-postgresql to own fork
This commit is contained in:
Sandro Santilli 2014-03-19 10:43:39 +01:00
parent 3b0d20aa96
commit f88d33fdb9
3 changed files with 29 additions and 5 deletions

3
npm-shrinkwrap.json generated
View File

@ -14,7 +14,8 @@
} }
}, },
"pg": { "pg": {
"version": "2.6.2", "version": "2.6.2-cdb1",
"from": "git://github.com/CartoDB/node-postgres.git#2.6.2-cdb1",
"dependencies": { "dependencies": {
"generic-pool": { "generic-pool": {
"version": "2.0.3" "version": "2.0.3"

View File

@ -18,7 +18,7 @@
"dependencies": { "dependencies": {
"underscore" : "~1.3.3", "underscore" : "~1.3.3",
"underscore.string": "~1.1.6", "underscore.string": "~1.1.6",
"pg": "~2.6.2", "pg": "git://github.com/CartoDB/node-postgres.git#2.6.2-cdb1",
"express": "~2.5.11", "express": "~2.5.11",
"cartodb-redis": "~0.3.0", "cartodb-redis": "~0.3.0",
"step": "0.0.x", "step": "0.0.x",

View File

@ -26,7 +26,7 @@ suiteSetup(function(done){
}); });
// See https://github.com/CartoDB/CartoDB-SQL-API/issues/135 // See https://github.com/CartoDB/CartoDB-SQL-API/issues/135
test.skip('does not hang server', function(done){ test('does not hang server', function(done){
//console.log("settings:"); console.dir(global.settings); //console.log("settings:"); console.dir(global.settings);
var db_host_backup = global.settings.db_host; var db_host_backup = global.settings.db_host;
var db_port_backup = global.settings.db_port; var db_port_backup = global.settings.db_port;
@ -45,8 +45,31 @@ test.skip('does not hang server', function(done){
}); });
}, },
function checkResponse(err, res) { function checkResponse(err, res) {
assert.ok(err); if ( err ) throw err;
assert.ok(err.message.match(/hang up/), err); assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.error);
var msg = parsed.error[0];
assert.ok(msg.match(/unexpected.*end/), msg);
return null;
},
function sendAnotherQuery() {
var next = this;
assert.response(app, {
url: '/api/v1/sql?q=SELECT+2',
method: 'GET',
headers: {host: 'vizzuality.localhost' }
},{}, function(res, err) {
next(err, res);
});
},
function checkResponse(err, res) {
if ( err ) throw err;
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.error);
var msg = parsed.error[0];
assert.ok(msg.match(/connect/), msg);
return null; return null;
}, },
function finish(err) { function finish(err) {