diff --git a/test/acceptance/app.auth.test.js b/test/acceptance/app.auth.test.js index dd648cfd..1f990275 100644 --- a/test/acceptance/app.auth.test.js +++ b/test/acceptance/app.auth.test.js @@ -49,7 +49,7 @@ describe('app.auth', function() { method: 'GET' }, {}, - function(res) { + function(err, res) { assert.equal(res.statusCode, scenario.statusCode, res.statusCode + ': ' + res.body); done(); } diff --git a/test/acceptance/app.test.js b/test/acceptance/app.test.js index b7d3aa7c..44fab364 100644 --- a/test/acceptance/app.test.js +++ b/test/acceptance/app.test.js @@ -23,6 +23,10 @@ var step = require('step'); describe('app.test', function() { + var RESPONSE_OK = { + statusCode: 200 + }; + var expected_cache_control = 'no-cache,max-age=31536000,must-revalidate,public'; var expected_rw_cache_control = 'no-cache,max-age=0,must-revalidate,public'; var expected_cache_control_persist = 'public,max-age=31536000'; @@ -31,7 +35,7 @@ it('GET /api/v1/version', function(done){ assert.response(server, { url: '/api/v1/version', method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200); var parsed = JSON.parse(res.body); var sqlapi_version = require(__dirname + '/../../package.json').version; @@ -47,7 +51,7 @@ it('GET /api/v1/sql', function(done){ method: 'GET' },{ status: 400 - }, function(res) { + }, function(err, res) { assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); assert.deepEqual(JSON.parse(res.body), {"error":["You must indicate a sql query"]}); @@ -62,7 +66,7 @@ it('GET /api/whatever/sql', function(done){ headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' },{ - }, function(res) { + }, function(err, res) { assert.equal(res.statusCode, 200, res.body); done(); }); @@ -75,7 +79,7 @@ it('GET /api/whatever/sql', function(done){ headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' },{ - }, function(res) { + }, function(err, res) { assert.equal(res.statusCode, 200, res.body); assert.equal( res.headers['access-control-allow-headers'], 'X-Requested-With, X-Prototype-Version, X-CSRF-Token' @@ -91,7 +95,7 @@ it('OPTIONS /api/x/sql', function(done){ url: '/api/x/sql?q=syntax%20error', headers: {host: 'vizzuality.cartodb.com'}, method: 'OPTIONS' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.body); assert.equal(res.body, ''); assert.equal( @@ -109,7 +113,7 @@ it('GET /api/v1/sql with SQL parameter on SELECT only. No oAuth included ', func url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&database=cartodb_test_user_1_db', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); // Check cache headers assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:public.untitle_table_4'); @@ -123,7 +127,7 @@ it('cache_policy=persist', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&database=cartodb_test_user_1_db&cache_policy=persist', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); // Check cache headers assert.ok(res.headers.hasOwnProperty('x-cache-channel')); @@ -139,7 +143,7 @@ it('GET /api/v1/sql with SQL parameter on SELECT only. no database param, just i url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); done(); }); @@ -149,7 +153,7 @@ it('GET /user/vizzuality/api/v1/sql with SQL parameter on SELECT only', function assert.response(server, { url: '/user/vizzuality/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4', method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); done(); }); @@ -164,18 +168,16 @@ it('SELECT from user-specific database', function(done){ url: '/api/v1/sql?q=SELECT+2+as+n', headers: {host: 'cartodb250user.cartodb.com'}, method: 'GET' - },{}, function(res) { + }, RESPONSE_OK, function(err, res) { global.settings.db_host = backupDBHost; - var err = null; try { - assert.equal(res.statusCode, 200, res.statusCode + ": " + res.body); - var parsed = JSON.parse(res.body); - assert.equal(parsed.rows.length, 1); - assert.equal(parsed.rows[0].n, 2); + var parsed = JSON.parse(res.body); + assert.equal(parsed.rows.length, 1); + assert.equal(parsed.rows[0].n, 2); } catch (e) { - err = e; + return done(e); } - done(err); + done(); }); }); @@ -187,18 +189,17 @@ it('SELECT with user-specific password', function(done){ url: '/api/v1/sql?q=SELECT+2+as+n&api_key=1234', headers: {host: 'cartodb250user.cartodb.com'}, method: 'GET' - },{}, function(res) { + }, RESPONSE_OK, function(err, res) { global.settings.db_user_pass = backupDBUserPass; - var err = null; try { assert.equal(res.statusCode, 200, res.statusCode + ": " + res.body); var parsed = JSON.parse(res.body); assert.equal(parsed.rows.length, 1); assert.equal(parsed.rows[0].n, 2); } catch (e) { - err = e; + return done(e); } - done(err); + return done(); }); }); @@ -208,7 +209,7 @@ function(done){ url: '/api/v1/sql?q=SELECT%20cartodb_id*2%20FROM%20untitle_table_4&api_key=1234', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); // Check cache headers assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:public.untitle_table_4'); @@ -230,7 +231,7 @@ function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:public.untitle_table_4'); var parsed = JSON.parse(res.body); @@ -290,7 +291,7 @@ it("paging", function(done){ req.headers['Content-Type'] = 'application/x-www-form-urlencoded'; req.data = data; } - assert.response(server, req, {}, function(res) { + assert.response(server, req, {}, function(err, res) { assert.equal(res.statusCode, 200, res.body); var parsed = JSON.parse(res.body); assert.equal(parsed.rows.length, nrows); @@ -319,7 +320,7 @@ it("paging starting with comment", function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - }, {}, function(res) { + }, {}, function(err, res) { assert.equal(res.statusCode, 200, res.body); var parsed = JSON.parse(res.body); assert.equal(parsed.rows.length, 3); @@ -338,7 +339,7 @@ it('POST /api/v1/sql with SQL parameter on SELECT only. no database param, just data: querystring.stringify({q: "SELECT * FROM untitle_table_4"}), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); done(); }); @@ -351,7 +352,7 @@ it('GET /api/v1/sql with INSERT. oAuth not used, so public user - should fail', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' },{ - }, function(res) { + }, function(err, res) { assert.equal(res.statusCode, 401, res.statusCode + ': ' + res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -368,7 +369,7 @@ it('GET /api/v1/sql with DROP TABLE. oAuth not used, so public user - should fai headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' },{ - }, function(res) { + }, function(err, res) { assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -386,9 +387,7 @@ it('GET /api/v1/sql with INSERT. header based db - should fail', function (done) method: 'GET' }, { status: 400 - }, function (res, err) { - done(err); - }); + }, done); }); // Check results from INSERT @@ -402,7 +401,7 @@ it('INSERT returns affected rows', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var out = JSON.parse(res.body); assert.ok(out.hasOwnProperty('time')); @@ -427,7 +426,7 @@ it('UPDATE returns affected rows', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var out = JSON.parse(res.body); assert.ok(out.hasOwnProperty('time')); @@ -452,7 +451,7 @@ it('DELETE returns affected rows', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var out = JSON.parse(res.body); assert.ok(out.hasOwnProperty('time')); @@ -477,7 +476,7 @@ it('INSERT with RETURNING returns all results', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var out = JSON.parse(res.body); assert.ok(out.hasOwnProperty('time')); @@ -501,7 +500,7 @@ it('UPDATE with RETURNING returns all results', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var out = JSON.parse(res.body); assert.ok(out.hasOwnProperty('time')); @@ -525,7 +524,7 @@ it('DELETE with RETURNING returns all results', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var out = JSON.parse(res.body); assert.ok(out.hasOwnProperty('time')); @@ -542,7 +541,7 @@ it('GET /api/v1/sql with SQL parameter on DROP TABLE. should fail', function(don url: "/api/v1/sql?q=DROP%20TABLE%20untitle_table_4", headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -564,7 +563,7 @@ it('Field name is not confused with UPDATE operation', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:public.private_table'); done(); @@ -579,7 +578,7 @@ it('CREATE TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // Check cache headers // See https://github.com/Vizzuality/CartoDB-SQL-API/issues/43 @@ -603,7 +602,7 @@ it('SELECT INTO with paging ', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { next(null, res); }); + },{}, function(err, res) { next(null, res); }); }, function check_res_test_fake_into_1(err, res) { assert.ifError(err); @@ -617,7 +616,7 @@ it('SELECT INTO with paging ', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { next(null, res); }); + },{}, function(err, res) { next(null, res); }); }, function check_res_drop_table(err, res) { assert.ifError(err); @@ -632,7 +631,7 @@ it('SELECT INTO with paging ', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { next(null, res); }); + },{}, function(err, res) { next(null, res); }); }, function check_drop(err, res) { assert.ifError(err); @@ -655,7 +654,7 @@ it('COPY TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { // We expect a problem, actually assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); @@ -673,7 +672,7 @@ it('COPY TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { // We expect a problem, actually assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); @@ -694,7 +693,7 @@ it('ALTER TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // Check cache headers // See https://github.com/Vizzuality/CartoDB-SQL-API/issues/43 @@ -713,7 +712,7 @@ it('multistatement insert, alter, select, begin, commit', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var parsedBody = JSON.parse(res.body); assert.equal(parsedBody.total_rows, 1); @@ -730,7 +729,7 @@ it('TRUNCATE TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); assert.ok(!res.hasOwnProperty('x-cache-channel')); assert.equal(res.headers['cache-control'], expected_rw_cache_control); @@ -743,7 +742,7 @@ it('TRUNCATE TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // table should not get a cache channel as it won't get invalidated assert.ok(!res.headers.hasOwnProperty('x-cache-channel')); @@ -764,7 +763,7 @@ it('REINDEX TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); assert.ok(!res.hasOwnProperty('x-cache-channel')); assert.equal(res.headers['cache-control'], expected_rw_cache_control); @@ -782,7 +781,7 @@ it('DROP TABLE with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // Check cache headers // See https://github.com/Vizzuality/CartoDB-SQL-API/issues/43 @@ -800,7 +799,7 @@ it('CREATE FUNCTION with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // Check cache headers // See https://github.com/Vizzuality/CartoDB-SQL-API/issues/43 @@ -818,7 +817,7 @@ it('DROP FUNCTION with GET and auth', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // Check cache headers // See https://github.com/Vizzuality/CartoDB-SQL-API/issues/43 @@ -833,7 +832,7 @@ it('sends a 400 when an unsupported format is requested', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=unknown', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 400, res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -847,7 +846,7 @@ it('GET /api/v1/sql with SQL parameter and no format, ensuring content-dispositi url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var ct = res.header('Content-Type'); assert.ok(/json/.test(ct), 'Default format is not JSON: ' + ct); @@ -864,7 +863,7 @@ it('POST /api/v1/sql with SQL parameter and no format, ensuring content-disposit data: querystring.stringify({q: "SELECT * FROM untitle_table_4" }), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var ct = res.header('Content-Type'); assert.ok(/json/.test(ct), 'Default format is not JSON: ' + ct); @@ -880,7 +879,7 @@ it('GET /api/v1/sql with SQL parameter and no format, but a filename', function( url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&filename=x', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var ct = res.header('Content-Type'); assert.ok(/json/.test(ct), 'Default format is not JSON: ' + ct); @@ -896,7 +895,7 @@ it('field named "the_geom_webmercator" is not skipped by default', function(done url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var row0 = JSON.parse(res.body).rows[0]; var checkfields = {'name':1, 'cartodb_id':1, 'the_geom':1, 'the_geom_webmercator':1}; @@ -916,7 +915,7 @@ it('skipfields controls included fields', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&skipfields=the_geom_webmercator,cartodb_id,unexistant', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var row0 = JSON.parse(res.body).rows[0]; var checkfields = {'name':1, 'cartodb_id':0, 'the_geom':1, 'the_geom_webmercator':0}; @@ -937,7 +936,7 @@ it('multiple skipfields parameter do not kill the backend', function(done){ '&skipfields=cartodb_id,unexistant', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var row0 = JSON.parse(res.body).rows[0]; var checkfields = {'name':1, 'cartodb_id':0, 'the_geom':1, 'the_geom_webmercator':0}; @@ -959,7 +958,7 @@ it('GET /api/v1/sql ensure cross domain set on errors', function(done){ method: 'GET' },{ status: 400 - }, function(res){ + }, function(err, res){ var cd = res.header('Access-Control-Allow-Origin'); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -1022,7 +1021,7 @@ function testSystemQueries(description, queries, statusErrorCode, apiKey) { method: 'GET', url: '/api/v1/sql?' + querystring.stringify(queryStringParams) }; - assert.response(server, request, function(response) { + assert.response(server, request, function(err, response) { assert.equal(response.statusCode, statusErrorCode); done(); }); @@ -1035,7 +1034,7 @@ it('GET decent error if domain is incorrect', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson', headers: {host: 'vizzualinot.cartodb.com'}, method: 'GET' - }, {}, function(res){ + }, {}, function(err, res){ assert.equal(res.statusCode, 404, res.statusCode + ( res.statusCode !== 200 ? ( ': ' + res.body ) : '')); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -1056,7 +1055,7 @@ it('GET decent error if SQL is broken', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res){ + },{}, function(err, res){ assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -1075,7 +1074,7 @@ it('numeric arrays are rendered as such', function(done){ }), headers: {host: 'vizzuality.localhost.lan:8080' }, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var out = JSON.parse(res.body); assert.ok(out.hasOwnProperty('time')); @@ -1105,7 +1104,7 @@ it('field names and types are exposed', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); assert.equal(_.keys(parsedBody.fields).length, 10); @@ -1132,7 +1131,7 @@ it('schema response takes skipfields into account', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); assert.equal(_.keys(parsedBody.fields).length, 2); @@ -1161,7 +1160,7 @@ it('numeric fields are rendered as numbers in JSON', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); var row = parsedBody.rows[0]; @@ -1202,7 +1201,7 @@ it('timezone info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { try { assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); @@ -1222,7 +1221,7 @@ it('timezone info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { try { assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); @@ -1242,7 +1241,7 @@ it('timezone info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { try { assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); @@ -1262,7 +1261,7 @@ it('timezone info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { try { assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); @@ -1284,7 +1283,6 @@ it('timezone info in JSON output', function(done){ it('notice and warning info in JSON output', function(done){ step( function addRaiseFunction() { - var next = this; assert.response(server, { url: '/api/v1/sql?' + querystring.stringify({ q: "create or replace function raise(lvl text, msg text) returns void as $$ begin if lvl = 'notice' " + @@ -1294,13 +1292,7 @@ it('notice and warning info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { - var err = null; - try { - assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); - } catch (e) { err = e; } - next(err); - }); + }, RESPONSE_OK, this); }, function raiseNotice(err) { assert.ifError(err); @@ -1311,15 +1303,15 @@ it('notice and warning info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { - var err = null; + }, RESPONSE_OK, function(err, res) { try { - assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); assert.ok(parsedBody.hasOwnProperty('notices'), 'Missing notices from result'); assert.equal(parsedBody.notices.length, 1); assert.equal(parsedBody.notices[0], 'hello notice'); - } catch (e) { err = e; } + } catch (e) { + return next(e); + } next(err); }); }, @@ -1332,15 +1324,15 @@ it('notice and warning info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { - var err = null; + }, RESPONSE_OK, function(err, res) { try { - assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); assert.ok(parsedBody.hasOwnProperty('warnings'), 'Missing warnings from result'); assert.equal(parsedBody.warnings.length, 1); assert.equal(parsedBody.warnings[0], 'hello warning'); - } catch (e) { err = e; } + } catch (e) { + return next(e); + } next(err); }); }, @@ -1354,10 +1346,8 @@ it('notice and warning info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { - var err = null; + }, RESPONSE_OK, function(err, res) { try { - assert.equal(res.statusCode, 200, res.body); var parsedBody = JSON.parse(res.body); assert.ok(parsedBody.hasOwnProperty('warnings'), 'Missing warnings from result'); assert.equal(parsedBody.warnings.length, 1); @@ -1365,12 +1355,13 @@ it('notice and warning info in JSON output', function(done){ assert.ok(parsedBody.hasOwnProperty('notices'), 'Missing notices from result'); assert.equal(parsedBody.notices.length, 1); assert.equal(parsedBody.notices[0], 'hello again notice'); - } catch (e) { err = e; } + } catch (e) { + return next(e); + } next(err); }); }, - function delRaiseFunction(err) { - var next = this; + function delRaiseFunction() { assert.response(server, { url: '/api/v1/sql?' + querystring.stringify({ q: "DROP function raise(text, text)", @@ -1378,16 +1369,15 @@ it('notice and warning info in JSON output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + }, RESPONSE_OK, function(err, res) { try { assert.equal(res.statusCode, 200, res.body); JSON.parse(res.body); - } catch (e) { err = new Error(err + ',' + e); } - next(err); + } catch (e) { + err = new Error(err + ',' + e); + } + done(err); }); - }, - function finish(err) { - done(err); } ); }); @@ -1400,7 +1390,7 @@ it('GET /api/v1/sql with SQL parameter on SELECT only should return CORS headers url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&database=cartodb_test_user_1_db', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); // Check cache headers assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:public.untitle_table_4'); @@ -1419,7 +1409,7 @@ it('GET with callback param returns wrapped result set with callback as jsonp', url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&callback=foo_jsonp', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); assert.ok(res.body.match(/foo\_jsonp\(.*\)/)); done(); @@ -1431,7 +1421,7 @@ it('GET with callback must return 200 status error even if it is an error', func url: "/api/v1/sql?q=DROP%20TABLE%20untitle_table_4&callback=foo_jsonp", headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var didRunJsonCallback = false; // jshint ignore:start @@ -1455,7 +1445,7 @@ it('GET with callback must return 200 status error even if it is an error', func { status: 400 }, - function(res) { + function(err, res) { assert.ok(res.body.match(/was not able to finish.*try again/i)); done(); }); diff --git a/test/acceptance/backend_crash.js b/test/acceptance/backend_crash.js index 6773ec3b..d6d338a1 100644 --- a/test/acceptance/backend_crash.js +++ b/test/acceptance/backend_crash.js @@ -30,14 +30,11 @@ it('does not hang server', function(done){ var server = require('../../app/server')(); step( function sendQuery() { - var next = this; assert.response(server, { url: '/api/v1/sql?q=SELECT+1', method: 'GET', headers: {host: 'vizzuality.localhost' } - },{}, function(res, err) { - next(err, res); - }); + },{}, this); }, function checkResponse(err, res) { assert.ifError(err); @@ -49,14 +46,11 @@ it('does not hang server', function(done){ return null; }, function sendAnotherQuery() { - var next = this; assert.response(server, { url: '/api/v1/sql?q=SELECT+2', method: 'GET', headers: {host: 'vizzuality.localhost' } - },{}, function(res, err) { - next(err, res); - }); + },{}, this); }, function checkResponse(err, res) { assert.ifError(err); diff --git a/test/acceptance/export/arraybuffer.js b/test/acceptance/export/arraybuffer.js index 93629604..2a297b85 100644 --- a/test/acceptance/export/arraybuffer.js +++ b/test/acceptance/export/arraybuffer.js @@ -16,7 +16,7 @@ it('GET /api/v1/sql as arraybuffer ', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); assert.equal(res.headers['content-type'], "application/octet-stream"); done(); @@ -31,7 +31,7 @@ it('GET /api/v1/sql as arraybuffer does not support geometry types ', function(d }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 400, res.body); var result = JSON.parse(res.body); assert.equal(result.error[0], "geometry types are not supported"); diff --git a/test/acceptance/export/csv.js b/test/acceptance/export/csv.js index e3c246f7..d9a46fa0 100644 --- a/test/acceptance/export/csv.js +++ b/test/acceptance/export/csv.js @@ -16,7 +16,7 @@ it('CSV format', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'CSV is not disposed as attachment: ' + cd); @@ -44,7 +44,7 @@ it('CSV format, bigger than 81920 bytes', function(done){ }), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.ok(res.body.length > 81920, 'CSV smaller than expected: ' + res.body.length); done(); }); @@ -57,7 +57,7 @@ it('CSV format from POST', function(done){ data: querystring.stringify({q: "SELECT * FROM untitle_table_4 LIMIT 1", format: 'csv'}), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'CSV is not disposed as attachment: ' + cd); @@ -73,7 +73,7 @@ it('CSV format, custom filename', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=csv&filename=mycsv.csv', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'CSV is not disposed as attachment: ' + cd); @@ -100,7 +100,7 @@ it('skipfields controls fields included in CSV output', function(done){ '&skipfields=unexistant,cartodb_id', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var row0 = res.body.substring(0, res.body.search(/[\n\r]/)).split(','); var checkFields = { name: true, cartodb_id: false, the_geom: true, the_geom_webmercator: true }; @@ -122,7 +122,7 @@ it('GET /api/v1/sql as csv', function(done){ '&format=csv', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var expected = 'cartodb_id,geom\r\n1,"SRID=4326;POINT(-3.699732 40.423012)"\r\n'; assert.equal(res.body, expected); @@ -136,7 +136,7 @@ it('GET /api/v1/sql as csv with no rows', function(done){ url: '/api/v1/sql?q=SELECT%20true%20WHERE%20false&format=csv', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var obtained_lines = res.body.split('\r\n'); assert.ok(obtained_lines.length <= 2, // may or may not have an header @@ -151,7 +151,7 @@ it('GET /api/v1/sql as csv, properly escaped', function(done){ url: '/api/v1/sql?q=SELECT%20cartodb_id,%20address%20FROM%20untitle_table_4%20LIMIT%201&format=csv', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var expected = 'cartodb_id,address\r\n1,"Calle de Pérez Galdós 9, Madrid, Spain"\r\n'; assert.equal(res.body, expected); @@ -163,7 +163,7 @@ it('GET /api/v1/sql as csv, concurrently', function(done){ var concurrency = 4; var waiting = concurrency; - function validate(res){ + function validate(err, res){ var expected = 'cartodb_id,address\r\n1,"Calle de Pérez Galdós 9, Madrid, Spain"\r\n'; assert.equal(res.body, expected); if ( ! --waiting ) { @@ -199,7 +199,7 @@ it('GET /api/v1/sql as csv, concurrently', function(done){ { status: 200 }, - function(res) { + function(err, res) { var headersPlusExtraLine = 2; assert.equal(res.body.split('\n').length, limit + headersPlusExtraLine); done(); diff --git a/test/acceptance/export/geojson.js b/test/acceptance/export/geojson.js index 656c29f6..3d9ab47a 100644 --- a/test/acceptance/export/geojson.js +++ b/test/acceptance/export/geojson.js @@ -23,7 +23,7 @@ it('GET /api/v1/sql with SQL parameter, ensuring content-disposition set to geoj url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'GEOJSON is not disposed as attachment: ' + cd); @@ -38,7 +38,7 @@ it('POST /api/v1/sql with SQL parameter, ensuring content-disposition set to geo data: querystring.stringify({q: "SELECT * FROM untitle_table_4", format: 'geojson' }), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'GEOJSON is not disposed as attachment: ' + cd); @@ -52,7 +52,7 @@ it('uses the last format parameter when multiple are used', function(done){ url: '/api/v1/sql?format=csv&q=SELECT%20*%20FROM%20untitle_table_4&format=geojson', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /filename=cartodb-query.geojson/gi.test(cd)); @@ -65,7 +65,7 @@ it('uses custom filename', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson&filename=x', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /filename=x.geojson/gi.test(cd), cd); @@ -78,7 +78,7 @@ it('does not include the_geom and the_geom_webmercator properties by default', f url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var parsed_body = JSON.parse(res.body); var row0 = parsed_body.features[0].properties; @@ -99,7 +99,7 @@ it('skipfields controls fields included in GeoJSON output', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson&skipfields=unexistant,cartodb_id', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var parsed_body = JSON.parse(res.body); var row0 = parsed_body.features[0].properties; @@ -124,7 +124,7 @@ it('GET /api/v1/sql as geojson limiting decimal places', function(done){ dp: '1'}), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var result = JSON.parse(res.body); assert.equal(1, checkDecimals(result.features[0].geometry.coordinates[0], '.')); @@ -139,7 +139,7 @@ it('GET /api/v1/sql as geojson with default dp as 6', function(done){ format: 'geojson'}), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var result = JSON.parse(res.body); assert.equal(6, checkDecimals(result.features[0].geometry.coordinates[0], '.')); @@ -155,7 +155,7 @@ it('null geometries in geojson output', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'GEOJSON is not disposed as attachment: ' + cd); @@ -180,7 +180,7 @@ it('stream response handle errors', function(done) { }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 400, res.body); var geoJson = JSON.parse(res.body); assert.ok(geoJson.error); @@ -198,7 +198,7 @@ it('stream response with empty result set has valid output', function(done) { }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var geoJson = JSON.parse(res.body); var expectedGeoJson = {"type": "FeatureCollection", "features": []}; diff --git a/test/acceptance/export/geopackage.js b/test/acceptance/export/geopackage.js index 68f7eabb..b7a9f5bf 100644 --- a/test/acceptance/export/geopackage.js +++ b/test/acceptance/export/geopackage.js @@ -15,7 +15,7 @@ describe('geopackage query', function(){ url: base_url, headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); assert.equal(res.headers["content-type"], "application/x-sqlite3; charset=utf-8"); assert.notEqual(res.headers["content-disposition"].indexOf(table_name + ".gpkg"), -1); @@ -35,7 +35,7 @@ describe('geopackage query', function(){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { var tmpfile = '/tmp/a_geopackage_file.gpkg'; try { fs.writeFileSync(tmpfile, res.body, 'binary'); diff --git a/test/acceptance/export/kml.js b/test/acceptance/export/kml.js index 0f8a69c1..b85d0e45 100644 --- a/test/acceptance/export/kml.js +++ b/test/acceptance/export/kml.js @@ -110,7 +110,7 @@ it('KML format, unauthenticated', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=kml', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'KML is not disposed as attachment: ' + cd); @@ -134,7 +134,7 @@ it('KML format, unauthenticated, POST', function(done){ data: 'q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=kml', headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'KML is not disposed as attachment: ' + cd); @@ -152,7 +152,7 @@ it('KML format, bigger than 81920 bytes', function(done){ }), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'KML is not disposed as attachment: ' + cd); @@ -167,7 +167,7 @@ it('KML format, skipfields', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=kml&skipfields=address,cartodb_id', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'KML is not disposed as attachment: ' + cd); @@ -190,7 +190,7 @@ it('KML format, unauthenticated, custom filename', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=kml&filename=kmltest', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'KML is not disposed as attachment: ' + cd); @@ -206,7 +206,7 @@ it('KML format, authenticated', function(done){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=kml&api_key=1234', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /filename=cartodb-query.kml/gi.test(cd), 'Unexpected KML filename: ' + cd); @@ -275,7 +275,7 @@ it('GET /api/v1/sql as kml with no rows', function(done){ url: '/api/v1/sql?q=SELECT%20true%20WHERE%20false&format=kml', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); // NOTE: GDAL-1.11+ added 'id="root_doc"' attribute to the output var pat = new RegExp('^<\\?xml version="1.0" encoding="utf-8" \\?>' + @@ -298,7 +298,7 @@ it('GET /api/v1/sql as kml with ending semicolon', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); // NOTE: GDAL-1.11+ added 'id="root_doc"' attribute to the output var pat = new RegExp('^<\\?xml version="1.0" encoding="utf-8" \\?>' + @@ -321,7 +321,7 @@ it('check point coordinates, unauthenticated', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var coords = extractCoordinates(res.body); assert(coords, 'No coordinates in ' + res.body); @@ -340,7 +340,7 @@ it('check point coordinates, authenticated', function(done){ }), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var coords = extractCoordinates(res.body); assert(coords, 'No coordinates in ' + res.body); @@ -366,7 +366,7 @@ it('check point coordinates, authenticated', function(done){ { status: 200 }, - function(res) { + function(err, res) { assert.equal(res.body.match(//g).length, limit); done(); } @@ -387,7 +387,7 @@ it('check point coordinates, authenticated', function(done){ { status: 200 }, - function(res) { + function(err, res) { assert.equal(res.body.match(//g).length, limit); done(); } @@ -411,7 +411,7 @@ it('check point coordinates, authenticated', function(done){ { status: 200 }, - function(res) { + function(err, res) { assert.equal(res.body.match(//g), null); done(); } diff --git a/test/acceptance/export/shapefile.js b/test/acceptance/export/shapefile.js index 76b4a864..9efaf104 100644 --- a/test/acceptance/export/shapefile.js +++ b/test/acceptance/export/shapefile.js @@ -18,15 +18,15 @@ it('SHP format, unauthenticated', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SHP is not disposed as attachment: ' + cd); assert.equal(true, /filename=cartodb-query.zip/gi.test(cd)); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); assert.ok(_.contains(zf.names, 'cartodb-query.shp'), 'SHP zipfile does not contain .shp: ' + zf.names); @@ -45,7 +45,7 @@ it('SHP format, unauthenticated, POST', function(done){ data: 'q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=shp', headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SHP is not disposed as attachment: ' + cd); @@ -63,7 +63,7 @@ it('SHP format, big size, POST', function(done){ }), headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SHP is not disposed as attachment: ' + cd); @@ -79,15 +79,15 @@ it('SHP format, unauthenticated, with custom filename', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SHP is not disposed as attachment: ' + cd); assert.equal(true, /filename=myshape.zip/gi.test(cd)); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); assert.ok(_.contains(zf.names, 'myshape.shp'), 'SHP zipfile does not contain .shp: ' + zf.names); @@ -105,16 +105,16 @@ it('SHP format, unauthenticated, with custom, dangerous filename', function(done headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var fname = "b_______a"; var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SHP is not disposed as attachment: ' + cd); assert.equal(true, /filename=b_______a.zip/gi.test(cd), 'Unexpected SHP filename: ' + cd); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); assert.ok(_.contains(zf.names, fname + '.shp'), 'SHP zipfile does not contain .shp: ' + zf.names); @@ -132,14 +132,14 @@ it('SHP format, authenticated', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /filename=cartodb-query.zip/gi.test(cd)); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); assert.ok(_.contains(zf.names, 'cartodb-query.shp'), 'SHP zipfile does not contain .shp: ' + zf.names); @@ -165,12 +165,12 @@ it('SHP format, unauthenticated, with utf8 data', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); var buffer = zf.readFileSync('myshape.dbf'); @@ -192,7 +192,7 @@ it('mixed type geometry', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); assert.equal(res.statusCode, 400, res.statusCode + ': ' +res.body); @@ -217,7 +217,7 @@ it('errors are not confused with warnings', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); assert.equal(res.statusCode, 400, res.statusCode + ': ' +res.body); @@ -240,12 +240,12 @@ it('skipfields controls fields included in SHP output', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); var buffer = zf.readFileSync('myshape.dbf'); @@ -259,14 +259,14 @@ it('skipfields controls fields included in SHP output', function(done){ it('SHP format, concurrently', function(done){ var concurrency = 1; var waiting = concurrency; - function validate(res){ + function validate(err, res){ var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SHP is not disposed as attachment: ' + cd); assert.equal(true, /filename=cartodb-query.zip/gi.test(cd)); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); assert.ok(_.contains(zf.names, 'cartodb-query.shp'), 'SHP zipfile does not contain .shp: ' + zf.names); @@ -307,14 +307,14 @@ it('point with null first', function(done){ headers: {host: 'vizzuality.cartodb.com'}, encoding: 'binary', method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /filename=cartodb-query.zip/gi.test(cd)); var tmpfile = '/tmp/myshape.zip'; - var err = fs.writeFileSync(tmpfile, res.body, 'binary'); - if (err) { - return done(err); + var writeErr = fs.writeFileSync(tmpfile, res.body, 'binary'); + if (writeErr) { + return done(writeErr); } var zf = new zipfile.ZipFile(tmpfile); assert.ok(_.contains(zf.names, 'cartodb-query.shp'), 'SHP zipfile does not contain .shp: ' + zf.names); @@ -346,7 +346,7 @@ it('point with null first', function(done){ { status: 200 }, - function(res, err) { + function(err, res) { if (err) { return done(err); } diff --git a/test/acceptance/export/spatialite.js b/test/acceptance/export/spatialite.js index 6110af29..7b116cb3 100644 --- a/test/acceptance/export/spatialite.js +++ b/test/acceptance/export/spatialite.js @@ -11,7 +11,7 @@ describe('spatialite query', function(){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=spatialite', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.statusCode, 200, res.body); assert.equal(res.headers["content-type"], "application/x-sqlite3; charset=utf-8"); var db = new sqlite.Database(':memory:', res.body); @@ -29,7 +29,7 @@ describe('spatialite query', function(){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=spatialite&filename=manolo', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { assert.equal(res.headers["content-type"], "application/x-sqlite3; charset=utf-8"); assert.notEqual(res.headers["content-disposition"].indexOf("manolo.sqlite"), -1); done(); @@ -41,7 +41,7 @@ describe('spatialite query', function(){ url: '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4%20LIMIT%201&format=spatialite', headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res) { + },{ }, function(err, res) { var db = new sqlite.Database(':memory:', res.body); var schemaQuery = "SELECT name, sql FROM sqlite_master WHERE type='table' ORDER BY name"; var qr = db.get(schemaQuery, function(err){ diff --git a/test/acceptance/export/svg.js b/test/acceptance/export/svg.js index 10b9ceb7..743d7a70 100644 --- a/test/acceptance/export/svg.js +++ b/test/acceptance/export/svg.js @@ -15,7 +15,7 @@ it('GET /api/v1/sql with SVG format', function(done){ url: '/api/v1/sql?' + query, headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.ok(/filename=cartodb-query.svg/gi.test(cd), cd); @@ -36,7 +36,7 @@ it('POST /api/v1/sql with SVG format', function(done){ data: query, headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' }, method: 'POST' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SVG is not disposed as attachment: ' + cd); @@ -58,7 +58,7 @@ it('GET /api/v1/sql with SVG format and custom filename', function(done){ url: '/api/v1/sql?' + query, headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.ok(/filename=mysvg.svg/gi.test(cd), cd); @@ -78,7 +78,7 @@ it('GET /api/v1/sql with SVG format and centered point', function(done){ url: '/api/v1/sql?' + query, headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.ok(/filename=cartodb-query.svg/gi.test(cd), cd); @@ -100,7 +100,7 @@ it('GET /api/v1/sql with SVG format and trimmed decimals', function(done){ url: '/api/v1/sql?' + querystring.stringify(queryobj), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.ok(/filename=cartodb-query.svg/gi.test(cd), cd); @@ -113,7 +113,7 @@ it('GET /api/v1/sql with SVG format and trimmed decimals', function(done){ url: '/api/v1/sql?' + querystring.stringify(queryobj), headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{}, function(res) { + },{}, function(err, res) { assert.equal(res.statusCode, 200, res.body); var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'SVG is not disposed as attachment: ' + cd); @@ -138,7 +138,7 @@ it('SVG format with "the_geom" in skipfields', function(done){ url: '/api/v1/sql?' + query, headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.deepEqual(res.headers['content-disposition'], 'inline'); @@ -158,7 +158,7 @@ it('SVG format with missing "the_geom" field', function(done){ url: '/api/v1/sql?' + query, headers: {host: 'vizzuality.cartodb.com'}, method: 'GET' - },{ }, function(res){ + },{ }, function(err, res){ assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body); assert.deepEqual(JSON.parse(res.body), { error:['column "the_geom" does not exist'] @@ -183,7 +183,7 @@ it('SVG format with missing "the_geom" field', function(done){ { status: 400 }, - function(res) { + function(err, res) { var parsedBody = JSON.parse(res.body); assert.deepEqual(Object.keys(parsedBody), ['error']); assert.deepEqual(parsedBody.error, ["division by zero"]); diff --git a/test/acceptance/export/topojson.js b/test/acceptance/export/topojson.js index 48516835..de3487ef 100644 --- a/test/acceptance/export/topojson.js +++ b/test/acceptance/export/topojson.js @@ -34,7 +34,7 @@ it('GET two polygons sharing an edge as topojson', function(done){ { status: 200 }, - function(res) { + function(err, res) { var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'TOPOJSON is not disposed as attachment: ' + cd); assert.equal(true, /filename=cartodb-query.topojson/gi.test(cd)); @@ -139,7 +139,7 @@ it('null geometries', function(done){ { status: 200 }, - function(res) { + function(err, res) { var cd = res.header('Content-Disposition'); assert.equal(true, /^attachment/.test(cd), 'TOPOJSON is not disposed as attachment: ' + cd); assert.equal(true, /filename=cartodb-query.topojson/gi.test(cd)); @@ -199,7 +199,7 @@ it('null geometries', function(done){ { status: 200 }, - function(res) { + function(err, res) { var parsedBody = JSON.parse(res.body); assert.equal(parsedBody.objects[0].properties.gid, 1, 'gid was expected property'); assert.ok(!parsedBody.objects[0].properties.name); @@ -220,7 +220,7 @@ it('null geometries', function(done){ { status: 200 }, - function(res) { + function(err, res) { assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); var didRunJsonCallback = false; // jshint ignore:start @@ -252,7 +252,7 @@ it('null geometries', function(done){ { status: 400 }, - function(res) { + function(err, res) { var parsedBody = JSON.parse(res.body); assert.deepEqual(Object.keys(parsedBody), ['error']); assert.deepEqual(parsedBody.error, ["division by zero"]); diff --git a/test/acceptance/frontend_abort.js b/test/acceptance/frontend_abort.js index 0ed809be..16cb1080 100644 --- a/test/acceptance/frontend_abort.js +++ b/test/acceptance/frontend_abort.js @@ -34,15 +34,12 @@ it('aborts request', function(done){ var timeout; step( function sendQuery() { - var next = this; assert.response(server, { url: '/api/v1/sql?q=SELECT+1', method: 'GET', timeout: 1, headers: {host: 'vizzuality.localhost' } - },{}, function(res, err) { - next(err, res); - }); + },{}, this); }, function checkResponse(err/*, res*/) { assert(err); // expect timeout diff --git a/test/acceptance/health_check.js b/test/acceptance/health_check.js index 5d14b280..7a94e6cb 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health_check.js @@ -31,7 +31,7 @@ describe('health checks', function() { { status: 200 }, - function(res, err) { + function(err, res) { assert.ok(!err); var parsed = JSON.parse(res.body); @@ -50,7 +50,7 @@ describe('health checks', function() { { status: 200 }, - function(res, err) { + function(err, res) { assert.ok(!err); var parsed = JSON.parse(res.body); diff --git a/test/acceptance/job.callback-template.test.js b/test/acceptance/job.callback-template.test.js index 9e672e14..52f90ba3 100644 --- a/test/acceptance/job.callback-template.test.js +++ b/test/acceptance/job.callback-template.test.js @@ -28,7 +28,7 @@ describe('Batch API callback templates', function () { data: querystring.stringify(jobDefinition) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return callback(err); } @@ -45,7 +45,7 @@ describe('Batch API callback templates', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return callback(err); } @@ -62,7 +62,7 @@ describe('Batch API callback templates', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return callback(err); } diff --git a/test/acceptance/job.fallback.test.js b/test/acceptance/job.fallback.test.js index 499ad708..2e23d4a2 100644 --- a/test/acceptance/job.fallback.test.js +++ b/test/acceptance/job.fallback.test.js @@ -69,7 +69,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -98,7 +98,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -137,7 +137,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -165,7 +165,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -204,7 +204,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -233,7 +233,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -272,7 +272,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -302,7 +302,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -342,7 +342,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -370,7 +370,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -409,7 +409,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -438,7 +438,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -478,7 +478,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -507,7 +507,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -546,7 +546,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -574,7 +574,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -615,7 +615,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -645,7 +645,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -687,7 +687,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -721,7 +721,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -763,7 +763,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -798,7 +798,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -841,7 +841,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -876,7 +876,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -918,7 +918,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -952,7 +952,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -991,7 +991,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1021,7 +1021,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1061,7 +1061,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1090,7 +1090,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1132,7 +1132,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1167,7 +1167,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1209,7 +1209,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1244,7 +1244,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1287,7 +1287,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1322,7 +1322,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1366,7 +1366,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1402,7 +1402,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1443,7 +1443,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1473,7 +1473,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1512,7 +1512,7 @@ describe('Batch API fallback job', function () { method: 'DELETE' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1549,7 +1549,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1579,7 +1579,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1621,7 +1621,7 @@ describe('Batch API fallback job', function () { method: 'DELETE' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1661,7 +1661,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1697,7 +1697,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1740,7 +1740,7 @@ describe('Batch API fallback job', function () { }) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } @@ -1779,7 +1779,7 @@ describe('Batch API fallback job', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return done(err); } diff --git a/test/acceptance/job.query.limit.test.js b/test/acceptance/job.query.limit.test.js index 5a94589d..9ce4e627 100644 --- a/test/acceptance/job.query.limit.test.js +++ b/test/acceptance/job.query.limit.test.js @@ -51,7 +51,7 @@ describe('job query limit', function() { }) }, { status: 400 - }, function (res) { + }, function (err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [expectedErrorMessage(queryTooLong)] }); done(); @@ -69,7 +69,7 @@ describe('job query limit', function() { }) }, { status: 201 - }, function (res) { + }, function (err, res) { var job = JSON.parse(res.body); assert.ok(job.job_id); done(); @@ -87,7 +87,7 @@ describe('job query limit', function() { }) }, { status: 400 - }, function (res) { + }, function (err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [expectedErrorMessage(queries)] }); done(); @@ -113,7 +113,7 @@ describe('job query limit', function() { }) }, { status: 400 - }, function (res) { + }, function (err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [expectedErrorMessage(fallbackQueries)] }); done(); diff --git a/test/acceptance/job.test.js b/test/acceptance/job.test.js index f5e2890c..ec4f45ee 100644 --- a/test/acceptance/job.test.js +++ b/test/acceptance/job.test.js @@ -36,7 +36,7 @@ describe('job module', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { job = JSON.parse(res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.ok(job.job_id); @@ -55,7 +55,7 @@ describe('job module', function() { data: querystring.stringify({}) }, { status: 400 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [ 'You must indicate a valid SQL' ] }); done(); @@ -72,7 +72,7 @@ describe('job module', function() { }) }, { status: 400 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [ 'You must indicate a valid SQL' ] }); done(); @@ -89,7 +89,7 @@ describe('job module', function() { }) }, { status: 401 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [ 'permission denied' ] }); done(); @@ -106,7 +106,7 @@ describe('job module', function() { }) }, { status: 404 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [ @@ -125,7 +125,7 @@ describe('job module', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var jobGot = JSON.parse(res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.equal(jobGot.query, "SELECT * FROM untitle_table_4"); @@ -141,7 +141,7 @@ describe('job module', function() { method: 'GET' }, { status: 401 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [ 'permission denied' ] }); done(); @@ -155,7 +155,7 @@ describe('job module', function() { method: 'GET' }, { status: 400 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); console.log(error); assert.deepEqual(error , { @@ -172,7 +172,7 @@ describe('job module', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { var jobCancelled = JSON.parse(res.body); assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); assert.equal(jobCancelled.job_id, job.job_id); @@ -190,7 +190,7 @@ describe('job module', function() { method: 'DELETE' }, { status: 401 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); assert.deepEqual(error, { error: [ 'permission denied' ] }); done(); @@ -204,7 +204,7 @@ describe('job module', function() { method: 'DELETE' }, { status: 404 - }, function(res) { + }, function(err, res) { var error = JSON.parse(res.body); assert.deepEqual(error , { error: [ diff --git a/test/acceptance/job.timing.test.js b/test/acceptance/job.timing.test.js index f5d479a9..ed88827b 100644 --- a/test/acceptance/job.timing.test.js +++ b/test/acceptance/job.timing.test.js @@ -28,7 +28,7 @@ describe('Batch API query timing', function () { data: querystring.stringify(jobDefinition) }, { status: 201 - }, function (res, err) { + }, function (err, res) { if (err) { return callback(err); } @@ -45,7 +45,7 @@ describe('Batch API query timing', function () { method: 'GET' }, { status: 200 - }, function (res, err) { + }, function (err, res) { if (err) { return callback(err); } diff --git a/test/acceptance/job.use-case-1.test.js b/test/acceptance/job.use-case-1.test.js index 68b47a07..c76004d9 100644 --- a/test/acceptance/job.use-case-1.test.js +++ b/test/acceptance/job.use-case-1.test.js @@ -53,7 +53,7 @@ describe('Use case 1: cancel and modify a done job', function () { }) }, { status: 201 - }, function (res) { + }, function (err, res) { doneJob = JSON.parse(res.body); done(); }); @@ -67,7 +67,7 @@ describe('Use case 1: cancel and modify a done job', function () { method: 'GET' }, { status: 200 - }, function (res) { + }, function (err, res) { var job = JSON.parse(res.body); if (job.status === "done") { clearInterval(interval); @@ -89,7 +89,7 @@ describe('Use case 1: cancel and modify a done job', function () { method: 'DELETE' }, { status: 400 - }, function(res) { + }, function(err, res) { var errors = JSON.parse(res.body); assert.equal(errors.error[0], "Cannot set status from done to cancelled"); done(); diff --git a/test/acceptance/job.use-case-10.test.js b/test/acceptance/job.use-case-10.test.js index 6dd5dc0e..52cfe3a6 100644 --- a/test/acceptance/job.use-case-10.test.js +++ b/test/acceptance/job.use-case-10.test.js @@ -57,7 +57,7 @@ describe('Use case 10: cancel and modify a done multiquery job', function () { }) }, { status: 201 - }, function (res) { + }, function (err, res) { doneJob = JSON.parse(res.body); done(); }); @@ -71,7 +71,7 @@ describe('Use case 10: cancel and modify a done multiquery job', function () { method: 'GET' }, { status: 200 - }, function (res) { + }, function (err, res) { var job = JSON.parse(res.body); if (job.status === "done") { clearInterval(interval); @@ -93,7 +93,7 @@ describe('Use case 10: cancel and modify a done multiquery job', function () { method: 'DELETE' }, { status: 400 - }, function(res) { + }, function(err, res) { var errors = JSON.parse(res.body); assert.equal(errors.error[0], "Cannot set status from done to cancelled"); done(); diff --git a/test/acceptance/job.use-case-2.test.js b/test/acceptance/job.use-case-2.test.js index 00fcabe6..244a6ac3 100644 --- a/test/acceptance/job.use-case-2.test.js +++ b/test/acceptance/job.use-case-2.test.js @@ -54,7 +54,7 @@ describe('Use case 2: cancel a running job', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { runningJob = JSON.parse(res.body); done(); }); @@ -68,7 +68,7 @@ describe('Use case 2: cancel a running job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "running") { clearInterval(interval); @@ -88,7 +88,7 @@ describe('Use case 2: cancel a running job', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { cancelledJob = JSON.parse(res.body); assert.equal(cancelledJob.status, "cancelled"); done(); @@ -102,7 +102,7 @@ describe('Use case 2: cancel a running job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "cancelled") { done(); @@ -119,7 +119,7 @@ describe('Use case 2: cancel a running job', function() { method: 'DELETE' }, { status: 400 - }, function(res) { + }, function(err, res) { var errors = JSON.parse(res.body); assert.equal(errors.error[0], "Cannot set status from cancelled to cancelled"); done(); diff --git a/test/acceptance/job.use-case-3.test.js b/test/acceptance/job.use-case-3.test.js index 546196ec..4f5eafb6 100644 --- a/test/acceptance/job.use-case-3.test.js +++ b/test/acceptance/job.use-case-3.test.js @@ -54,7 +54,7 @@ describe('Use case 3: cancel a pending job', function() { }) }, { status: 201 - }, function (res) { + }, function (err, res) { runningJob = JSON.parse(res.body); done(); }); @@ -70,7 +70,7 @@ describe('Use case 3: cancel a pending job', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { pendingJob = JSON.parse(res.body); done(); }); @@ -84,7 +84,7 @@ describe('Use case 3: cancel a pending job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "pending") { clearInterval(interval); @@ -104,7 +104,7 @@ describe('Use case 3: cancel a pending job', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { var jobGot = JSON.parse(res.body); assert.equal(jobGot.job_id, pendingJob.job_id); assert.equal(jobGot.status, "cancelled"); @@ -119,7 +119,7 @@ describe('Use case 3: cancel a pending job', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { var cancelledJob = JSON.parse(res.body); assert.equal(cancelledJob.status, "cancelled"); done(); diff --git a/test/acceptance/job.use-case-4.test.js b/test/acceptance/job.use-case-4.test.js index ceaf33e1..2c24af96 100644 --- a/test/acceptance/job.use-case-4.test.js +++ b/test/acceptance/job.use-case-4.test.js @@ -54,7 +54,7 @@ describe('Use case 4: modify a pending job', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { runningJob = JSON.parse(res.body); done(); }); @@ -70,7 +70,7 @@ describe('Use case 4: modify a pending job', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { pendingJob = JSON.parse(res.body); done(); }); @@ -84,7 +84,7 @@ describe('Use case 4: modify a pending job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "pending") { clearInterval(interval); @@ -104,7 +104,7 @@ describe('Use case 4: modify a pending job', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { var cancelledJob = JSON.parse(res.body); assert.equal(cancelledJob.status, "cancelled"); done(); diff --git a/test/acceptance/job.use-case-5.test.js b/test/acceptance/job.use-case-5.test.js index 6f41b964..a4581608 100644 --- a/test/acceptance/job.use-case-5.test.js +++ b/test/acceptance/job.use-case-5.test.js @@ -53,7 +53,7 @@ describe('Use case 5: modify a running job', function() { }) }, { status: 201 - }, function (res) { + }, function (err, res) { runningJob = JSON.parse(res.body); done(); }); @@ -67,7 +67,7 @@ describe('Use case 5: modify a running job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "running") { clearInterval(interval); @@ -87,7 +87,7 @@ describe('Use case 5: modify a running job', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { var cancelledJob = JSON.parse(res.body); assert.equal(cancelledJob.status, "cancelled"); done(); diff --git a/test/acceptance/job.use-case-6.test.js b/test/acceptance/job.use-case-6.test.js index abf69696..8f56c546 100644 --- a/test/acceptance/job.use-case-6.test.js +++ b/test/acceptance/job.use-case-6.test.js @@ -53,7 +53,7 @@ describe('Use case 6: modify a done job', function() { }) }, { status: 201 - }, function (res) { + }, function (err, res) { doneJob = JSON.parse(res.body); done(); }); @@ -67,7 +67,7 @@ describe('Use case 6: modify a done job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "done") { clearInterval(interval); diff --git a/test/acceptance/job.use-case-7.test.js b/test/acceptance/job.use-case-7.test.js index c867d5b9..1180078a 100644 --- a/test/acceptance/job.use-case-7.test.js +++ b/test/acceptance/job.use-case-7.test.js @@ -53,7 +53,7 @@ describe('Use case 7: cancel a job with quotes', function() { }) }, { status: 201 - }, function (res) { + }, function (err, res) { runningJob = JSON.parse(res.body); done(); }); @@ -67,7 +67,7 @@ describe('Use case 7: cancel a job with quotes', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "running") { clearInterval(interval); @@ -87,7 +87,7 @@ describe('Use case 7: cancel a job with quotes', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { var cancelledJob = JSON.parse(res.body); assert.equal(cancelledJob.status, "cancelled"); done(); diff --git a/test/acceptance/job.use-case-8.test.js b/test/acceptance/job.use-case-8.test.js index dd42921a..41863349 100644 --- a/test/acceptance/job.use-case-8.test.js +++ b/test/acceptance/job.use-case-8.test.js @@ -58,7 +58,7 @@ describe('Use case 8: cancel a running multiquery job', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { runningJob = JSON.parse(res.body); done(); }); @@ -72,7 +72,7 @@ describe('Use case 8: cancel a running multiquery job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "running") { clearInterval(interval); @@ -92,7 +92,7 @@ describe('Use case 8: cancel a running multiquery job', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { cancelledJob = JSON.parse(res.body); assert.equal(cancelledJob.status, "cancelled"); done(); @@ -106,7 +106,7 @@ describe('Use case 8: cancel a running multiquery job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "cancelled") { done(); @@ -123,7 +123,7 @@ describe('Use case 8: cancel a running multiquery job', function() { method: 'DELETE' }, { status: 400 - }, function(res) { + }, function(err, res) { var errors = JSON.parse(res.body); assert.equal(errors.error[0], "Cannot set status from cancelled to cancelled"); done(); diff --git a/test/acceptance/job.use-case-9.test.js b/test/acceptance/job.use-case-9.test.js index 8308bcc3..3ba2cd5f 100644 --- a/test/acceptance/job.use-case-9.test.js +++ b/test/acceptance/job.use-case-9.test.js @@ -57,7 +57,7 @@ describe('Use case 9: modify a pending multiquery job', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { runningJob = JSON.parse(res.body); done(); }); @@ -76,7 +76,7 @@ describe('Use case 9: modify a pending multiquery job', function() { }) }, { status: 201 - }, function(res) { + }, function(err, res) { pendingJob = JSON.parse(res.body); done(); }); @@ -90,7 +90,7 @@ describe('Use case 9: modify a pending multiquery job', function() { method: 'GET' }, { status: 200 - }, function(res) { + }, function(err, res) { var job = JSON.parse(res.body); if (job.status === "pending") { clearInterval(interval); @@ -110,7 +110,7 @@ describe('Use case 9: modify a pending multiquery job', function() { method: 'DELETE' }, { status: 200 - }, function(res) { + }, function(err, res) { var cancelledJob = JSON.parse(res.body); assert.equal(cancelledJob.status, "cancelled"); done(); diff --git a/test/acceptance/last-modified-header.js b/test/acceptance/last-modified-header.js index 5f0db6df..09e0c606 100644 --- a/test/acceptance/last-modified-header.js +++ b/test/acceptance/last-modified-header.js @@ -48,7 +48,7 @@ describe('last modified header', function() { { statusCode: 200 }, - function(res) { + function(err, res) { assert.equal(res.headers['last-modified'], scenario.expectedLastModified); done(); } @@ -77,7 +77,7 @@ describe('last modified header', function() { { statusCode: 200 }, - function(res) { + function(err, res) { Date.now = dateNowFn; assert.equal(res.headers['last-modified'], new Date(fixedDateNow).toUTCString()); done(); @@ -106,7 +106,7 @@ describe('last modified header', function() { { statusCode: 200 }, - function(res) { + function(err, res) { Date.now = dateNowFn; assert.equal(res.headers['last-modified'], new Date(fixedDateNow).toUTCString()); done(); diff --git a/test/acceptance/logging.js b/test/acceptance/logging.js index da348f5b..65a308d6 100644 --- a/test/acceptance/logging.js +++ b/test/acceptance/logging.js @@ -105,7 +105,7 @@ describe('Logging SQL query on POST requests', function() { return result; }; - assert.response(server, scenario.request, RESPONSE_OK, function(res, err) { + assert.response(server, scenario.request, RESPONSE_OK, function(err) { assert.ok(!err); assert.equal(called, 1); @@ -137,7 +137,7 @@ describe('Logging SQL query on POST requests', function() { } }, RESPONSE_OK, - function(res, err) { + function(err) { assert.ok(!err); assert.equal(called, 1); diff --git a/test/acceptance/query-tables-api-cache.js b/test/acceptance/query-tables-api-cache.js index 5880e634..ee7126ac 100644 --- a/test/acceptance/query-tables-api-cache.js +++ b/test/acceptance/query-tables-api-cache.js @@ -17,7 +17,7 @@ describe('query-tables-api', function() { { status: 200 }, - function(res) { + function(err, res) { callback(null, JSON.parse(res.body)); } ); @@ -38,7 +38,7 @@ describe('query-tables-api', function() { }; it('should create a key in affected tables cache', function(done) { - assert.response(server, request, RESPONSE_OK, function(res, err) { + assert.response(server, request, RESPONSE_OK, function(err) { assert.ok(!err, err); getCacheStatus(function(err, cacheStatus) { @@ -52,7 +52,7 @@ describe('query-tables-api', function() { }); it('should use cache to retrieve affected tables', function(done) { - assert.response(server, request, RESPONSE_OK, function(res, err) { + assert.response(server, request, RESPONSE_OK, function(err) { assert.ok(!err, err); getCacheStatus(function(err, cacheStatus) { @@ -76,7 +76,7 @@ describe('query-tables-api', function() { }, method: 'GET' }; - assert.response(server, authenticatedRequest, RESPONSE_OK, function(res, err) { + assert.response(server, authenticatedRequest, RESPONSE_OK, function(err) { assert.ok(!err, err); getCacheStatus(function(err, cacheStatus) { diff --git a/test/acceptance/regressions.js b/test/acceptance/regressions.js index 7d13615e..c18ea822 100644 --- a/test/acceptance/regressions.js +++ b/test/acceptance/regressions.js @@ -26,13 +26,13 @@ describe('regressions', function() { }; assert.response(server, createRequest('CREATE TABLE "foo.bar" (a int);'), responseOk, - function(res, err) { + function(err) { if (err) { return done(err); } assert.response(server, createRequest('INSERT INTO "foo.bar" (a) values (1), (2)'), responseOk, - function(res, err) { + function(err, res) { if (err) { return done(err); } @@ -40,7 +40,7 @@ describe('regressions', function() { assert.equal(parsedBody.total_rows, 2); assert.response(server, createRequest('SELECT * FROM "foo.bar"'), responseOk, - function(res, err) { + function(err, res) { if (err) { return done(err); } diff --git a/test/acceptance/stream-responses.js b/test/acceptance/stream-responses.js index cc6c7e6d..237cc9de 100644 --- a/test/acceptance/stream-responses.js +++ b/test/acceptance/stream-responses.js @@ -35,7 +35,7 @@ describe('stream-responses', function() { server, createFailingQueryRequest(), okResponse, - function(res) { + function(err, res) { var parsedBody = JSON.parse(res.body); assert.equal(parsedBody.rows.length, 2); assert.deepEqual(parsedBody.fields, { @@ -57,7 +57,7 @@ describe('stream-responses', function() { server, createFailingQueryRequest('geojson'), okResponse, - function(res) { + function(err, res) { var parsedBody = JSON.parse(res.body); assert.equal(parsedBody.features.length, 2); assert.deepEqual(parsedBody.error, ["division by zero"]); diff --git a/test/acceptance/surrogate-key.js b/test/acceptance/surrogate-key.js index 8254bbed..f460f556 100644 --- a/test/acceptance/surrogate-key.js +++ b/test/acceptance/surrogate-key.js @@ -40,7 +40,7 @@ describe('Surrogate-Key header', function() { function tableNamesInSurrogateKeyHeader(expectedTableNames, done) { - return function(res) { + return function(err, res) { surrogateKeyHasTables(res.headers['surrogate-key'], expectedTableNames); done(); }; @@ -84,7 +84,7 @@ describe('Surrogate-Key header', function() { it('should not add header for functions', function(done) { var sql = "SELECT format('%s', 'wadus')"; - assert.response(server, createGetRequest(sql), RESPONSE_OK, function(res) { + assert.response(server, createGetRequest(sql), RESPONSE_OK, function(err, res) { assert.ok(!res.headers.hasOwnProperty('surrogate-key'), res.headers['surrogate-key']); done(); }); @@ -92,7 +92,7 @@ describe('Surrogate-Key header', function() { it('should not add header for CDB_QueryTables', function(done) { var sql = "SELECT CDB_QueryTablesText('select * from untitle_table_4')"; - assert.response(server, createGetRequest(sql), RESPONSE_OK, function(res) { + assert.response(server, createGetRequest(sql), RESPONSE_OK, function(err, res) { assert.ok(!res.headers.hasOwnProperty('surrogate-key'), res.headers['surrogate-key']); done(); }); @@ -100,7 +100,7 @@ describe('Surrogate-Key header', function() { it('should not add header for non table results', function(done) { var sql = "SELECT 'wadus'::text"; - assert.response(server, createGetRequest(sql), RESPONSE_OK, function(res) { + assert.response(server, createGetRequest(sql), RESPONSE_OK, function(err, res) { assert.ok(!res.headers.hasOwnProperty('surrogate-key'), res.headers['surrogate-key']); done(); }); diff --git a/test/acceptance/timeout.js b/test/acceptance/timeout.js index 1f3d749e..24464cf1 100644 --- a/test/acceptance/timeout.js +++ b/test/acceptance/timeout.js @@ -29,14 +29,11 @@ it('after configured milliseconds', function(done){ var server = require('../../app/server')(); step( function sendLongQuery() { - var next = this; assert.response(server, { url: '/api/v1/sql?q=SELECT+count(*)+FROM+generate_series(1,100000)', method: 'GET', headers: {host: 'vizzuality.localhost' } - },{}, function(res, err) { - next(err, res); - }); + },{}, this); }, function checkResponse(err/*, res*/) { assert.ok(err); diff --git a/test/acceptance/x-cache-channel.js b/test/acceptance/x-cache-channel.js index 7b5708a3..d6effc9e 100644 --- a/test/acceptance/x-cache-channel.js +++ b/test/acceptance/x-cache-channel.js @@ -39,7 +39,7 @@ describe('X-Cache-Channel header', function() { } function tableNamesInCacheChannelHeader(expectedTableNames, done) { - return function(res) { + return function(err, res) { xCacheChannelHeaderHasTables(res.headers['x-cache-channel'], expectedTableNames); done(); }; @@ -83,7 +83,7 @@ describe('X-Cache-Channel header', function() { it('should not add header for functions', function(done) { var sql = "SELECT format('%s', 'wadus')"; - assert.response(server, createGetRequest(sql), RESPONSE_OK, function(res) { + assert.response(server, createGetRequest(sql), RESPONSE_OK, function(err, res) { assert.ok(!res.headers.hasOwnProperty('x-cache-channel'), res.headers['x-cache-channel']); done(); }); @@ -91,7 +91,7 @@ describe('X-Cache-Channel header', function() { it('should not add header for CDB_QueryTables', function(done) { var sql = "SELECT CDB_QueryTablesText('select * from untitle_table_4')"; - assert.response(server, createGetRequest(sql), RESPONSE_OK, function(res) { + assert.response(server, createGetRequest(sql), RESPONSE_OK, function(err, res) { assert.ok(!res.headers.hasOwnProperty('x-cache-channel'), res.headers['x-cache-channel']); done(); }); @@ -99,7 +99,7 @@ describe('X-Cache-Channel header', function() { it('should not add header for non table results', function(done) { var sql = "SELECT 'wadus'::text"; - assert.response(server, createGetRequest(sql), RESPONSE_OK, function(res) { + assert.response(server, createGetRequest(sql), RESPONSE_OK, function(err, res) { assert.ok(!res.headers.hasOwnProperty('x-cache-channel'), res.headers['x-cache-channel']); done(); }); diff --git a/test/support/assert.js b/test/support/assert.js index 64774ef6..bc855ccc 100644 --- a/test/support/assert.js +++ b/test/support/assert.js @@ -9,7 +9,7 @@ var assert = module.exports = exports = require('assert'); * @param {Server} server * @param {Object} req * @param {Object|Function} res - * @param {String|Function} msg + * @param {String|Function|Object} msg */ assert.response = function(server, req, res, msg){ var port = 5555; @@ -106,7 +106,7 @@ assert.response = function(server, req, res, msg){ request.on('error', function(err){ check(); - callback(null, err); + callback(err); }); request.on('response', function(response){ @@ -163,7 +163,7 @@ assert.response = function(server, req, res, msg){ } } - callback(response); + callback(null, response); }); });