Change callback signature in assert.response

This commit is contained in:
Raul Ochoa 2016-09-26 14:37:40 +02:00
parent 8d74b9dcda
commit c9846a2437
38 changed files with 274 additions and 286 deletions

View File

@ -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();
}

View File

@ -31,7 +31,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 +47,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 +62,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 +75,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 +91,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 +109,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 +123,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 +139,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 +149,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,7 +164,7 @@ 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) {
},{}, function(err, res) {
global.settings.db_host = backupDBHost;
var err = null;
try {
@ -187,7 +187,7 @@ 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) {
},{}, function(err, res) {
global.settings.db_user_pass = backupDBUserPass;
var err = null;
try {
@ -208,7 +208,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 +230,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 +290,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 +319,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 +338,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 +351,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 +368,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,7 +386,7 @@ it('GET /api/v1/sql with INSERT. header based db - should fail', function (done)
method: 'GET'
}, {
status: 400
}, function (res, err) {
}, function (err, res) {
done(err);
});
});
@ -402,7 +402,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 +427,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 +452,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 +477,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 +501,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 +525,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 +542,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 +564,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 +579,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 +603,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 +617,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 +632,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 +655,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 +673,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 +694,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 +713,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 +730,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 +743,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 +764,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 +782,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 +800,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 +818,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 +833,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 +847,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 +864,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 +880,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 +896,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 +916,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 +937,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 +959,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 +1022,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 +1035,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 +1056,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 +1075,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 +1105,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 +1132,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 +1161,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 +1202,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 +1222,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 +1242,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 +1262,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);
@ -1294,7 +1294,7 @@ it('notice and warning info in JSON output', function(done){
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{ }, function(res) {
},{ }, function(err, res) {
var err = null;
try {
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
@ -1311,7 +1311,7 @@ it('notice and warning info in JSON output', function(done){
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{}, function(res) {
},{}, function(err, res) {
var err = null;
try {
assert.equal(res.statusCode, 200, res.body);
@ -1332,7 +1332,7 @@ it('notice and warning info in JSON output', function(done){
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{}, function(res) {
},{}, function(err, res) {
var err = null;
try {
assert.equal(res.statusCode, 200, res.body);
@ -1354,7 +1354,7 @@ it('notice and warning info in JSON output', function(done){
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{}, function(res) {
},{}, function(err, res) {
var err = null;
try {
assert.equal(res.statusCode, 200, res.body);
@ -1378,7 +1378,7 @@ it('notice and warning 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);
JSON.parse(res.body);
@ -1400,7 +1400,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 +1419,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 +1431,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 +1455,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();
});

View File

@ -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);

View File

@ -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");

View File

@ -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();

View File

@ -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": []};

View File

@ -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');

View File

@ -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(/<Placemark>/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(/<Placemark>/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(/<Placemark>/g), null);
done();
}

View File

@ -18,7 +18,7 @@ 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);
@ -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,7 +79,7 @@ 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);
@ -105,7 +105,7 @@ 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');
@ -132,7 +132,7 @@ 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));
@ -165,7 +165,7 @@ 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');
@ -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,7 +240,7 @@ 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');
@ -259,7 +259,7 @@ 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));
@ -307,7 +307,7 @@ 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));
@ -346,7 +346,7 @@ it('point with null first', function(done){
{
status: 200
},
function(res, err) {
function(err, res) {
if (err) {
return done(err);
}

View File

@ -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){

View File

@ -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"]);

View File

@ -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"]);

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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: [

View File

@ -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);
}

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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, res) {
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);

View File

@ -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, res) {
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, res) {
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) {

View File

@ -26,13 +26,13 @@ describe('regressions', function() {
};
assert.response(server, createRequest('CREATE TABLE "foo.bar" (a int);'), responseOk,
function(res, err) {
function(err, res) {
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);
}

View File

@ -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"]);

View File

@ -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();
});

View File

@ -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);

View File

@ -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();
});

View File

@ -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);
});
});