2018-10-24 21:42:33 +08:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-04 16:50:14 +08:00
|
|
|
require('../helper');
|
|
|
|
|
2019-10-04 00:24:39 +08:00
|
|
|
const server = require('../../lib/server')();
|
2018-05-04 21:27:56 +08:00
|
|
|
const assert = require('../support/assert');
|
2018-05-04 16:50:14 +08:00
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
describe('query-multipart', function () {
|
|
|
|
it('make query from a multipart form', function (done) {
|
2018-05-04 16:50:14 +08:00
|
|
|
assert.response(server, {
|
|
|
|
url: '/api/v1/sql',
|
|
|
|
formData: {
|
|
|
|
q: 'SELECT 2 as n'
|
|
|
|
},
|
2019-12-24 01:19:08 +08:00
|
|
|
headers: { host: 'vizzuality.cartodb.com' },
|
2018-05-04 16:50:14 +08:00
|
|
|
method: 'POST'
|
2019-12-24 01:19:08 +08:00
|
|
|
}, {}, function (err, res) {
|
2018-05-04 16:50:14 +08:00
|
|
|
assert.ifError(err);
|
|
|
|
const response = JSON.parse(res.body);
|
2019-12-26 21:01:18 +08:00
|
|
|
assert.strictEqual(typeof (response.time) !== 'undefined', true);
|
2018-05-04 16:50:14 +08:00
|
|
|
assert.strictEqual(response.total_rows, 1);
|
2019-12-24 01:19:08 +08:00
|
|
|
assert.deepStrictEqual(response.rows, [{ n: 2 }]);
|
2018-05-04 16:50:14 +08:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|