2018-10-24 21:42:33 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-04 00:24:39 +08:00
|
|
|
var server = require('../../lib/server')();
|
2017-12-02 01:11:32 +08:00
|
|
|
var assert = require('../support/assert');
|
|
|
|
|
2018-10-24 21:42:33 +08:00
|
|
|
describe('error handler', function () {
|
2017-12-02 01:11:32 +08:00
|
|
|
it('should returns a errors header', function (done) {
|
|
|
|
const errorHeader = {
|
|
|
|
detail: undefined,
|
|
|
|
hint: undefined,
|
|
|
|
context: undefined,
|
|
|
|
statusCode: 400,
|
|
|
|
message: 'You must indicate a sql query'
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.response(server, {
|
|
|
|
url: '/api/v1/sql',
|
2019-12-24 01:19:08 +08:00
|
|
|
headers: { host: 'vizzuality.cartodb.com' },
|
2017-12-02 01:11:32 +08:00
|
|
|
method: 'GET'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
status: 400,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8',
|
|
|
|
'X-SQLAPI-Errors': JSON.stringify(errorHeader)
|
|
|
|
}
|
2018-10-24 21:42:33 +08:00
|
|
|
},
|
2019-12-24 01:19:08 +08:00
|
|
|
function (err) {
|
2017-12-02 01:11:32 +08:00
|
|
|
assert.ifError(err);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-12-13 00:16:40 +08:00
|
|
|
});
|