CartoDB-SQL-API/test/unit/query_info.test.js

50 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-05-22 01:13:44 +08:00
const assert = require('assert');
const queryInfo = require('../../app/utils/query_info');
describe('query info', function () {
describe('copy format', function() {
describe('csv', function() {
const csvValidQueries = [
"COPY copy_endpoints_test (id, name) FROM STDIN WITH (FORMAT CSV, DELIMITER ',', HEADER true)",
"COPY copy_endpoints_test (id, name) FROM STDIN WITH (FORMAT CSV, DELIMITER ',', HEADER true)",
"COPY copy_endpoints_test (id, name) FROM STDIN WITH (FORMAT CSV , DELIMITER ',', HEADER true)",
"COPY copy_endpoints_test (id, name) FROM STDIN WITH (FORMAT CSV)",
];
csvValidQueries.forEach(query => {
it(query, function() {
const result = queryInfo.getFormatFromCopyQuery(query);
assert.equal(result, 'CSV');
});
});
});
describe('text', function() {
const csvValidQueries = [
"COPY copy_endpoints_test (id, name) FROM STDIN WITH (FORMAT TEXT)",
"COPY copy_endpoints_test (id, name) FROM STDIN",
];
csvValidQueries.forEach(query => {
it(query, function() {
const result = queryInfo.getFormatFromCopyQuery(query);
assert.equal(result, 'TEXT');
});
});
});
describe('text', function() {
const csvValidQueries = [
"COPY copy_endpoints_test (id, name) FROM STDIN WITH (FORMAT BINARY)",
];
csvValidQueries.forEach(query => {
it(query, function() {
const result = queryInfo.getFormatFromCopyQuery(query);
assert.equal(result, 'BINARY');
});
});
});
});
});