test: drop statment tests

This commit is contained in:
wewoor 2023-05-11 19:06:19 +08:00
parent 65a754e533
commit 7b7c2ab8d8
6 changed files with 50 additions and 41 deletions

View File

@ -1,49 +1,39 @@
import FlinkSQL from "../../../../src/parser/flinksql"; import FlinkSQL from "../../../../src/parser/flinksql";
import { readSQL } from "../../../helper";
describe('FlinkSQL Create Table Syntax Tests', () => { const features = {
table: readSQL(__dirname, 'dropTable.sql'),
view: readSQL(__dirname, 'dropView.sql'),
function: readSQL(__dirname, 'dropFunction.sql'),
catalog: readSQL(__dirname, 'dropCatalog.sql'),
database: readSQL(__dirname, 'dropDatabase.sql'),
};
describe('FlinkSQL Drop Statements Tests', () => {
const parser = new FlinkSQL(); const parser = new FlinkSQL();
// Drop statements features.table.forEach((sql) => {
test('Test Simple Drop Catalog Statement', () => { it(sql, () => {
const sql = ` expect(parser.validate(sql).length).toBe(0);
DROP CATALOG catalog1;
DROP CATALOG IF EXISTS catalog2;
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
}); });
test('Test Simple Drop Table Statement', () => {
const sql = `
DROP TABLE Orders;
DROP TABLE IF EXISTS Orders;
DROP TEMPORARY TABLE IF EXISTS Orders;
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
}); });
test('Test Simple Drop Database Statement', () => { features.view.forEach((sql) => {
const sql = ` it(sql, () => {
DROP DATABASE Orders; expect(parser.validate(sql).length).toBe(0);
DROP DATABASE IF EXISTS Orders RESTRICT;
DROP DATABASE IF EXISTS Orders CASCADE;
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
}); });
test('Test Simple Drop View Statement', () => {
const sql = `
DROP VIEW Orders;
DROP TEMPORARY VIEW IF EXISTS Orders;
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
}); });
test('Test Simple Drop Function Statement', () => { features.function.forEach((sql) => {
const sql = ` it(sql, () => {
DROP FUNCTION Orders; expect(parser.validate(sql).length).toBe(0);
DROP TEMPORARY FUNCTION IF EXISTS Orders; });
DROP TEMPORARY SYSTEM FUNCTION IF EXISTS Orders; });
`; features.catalog.forEach((sql) => {
const result = parser.validate(sql); it(sql, () => {
expect(result.length).toBe(0); expect(parser.validate(sql).length).toBe(0);
});
});
features.database.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
}); });
}); });

View File

@ -0,0 +1,3 @@
DROP CATALOG catalog1;
DROP CATALOG IF EXISTS catalog2;

View File

@ -0,0 +1,3 @@
DROP DATABASE Orders;
DROP DATABASE IF EXISTS Orders RESTRICT;
DROP DATABASE IF EXISTS Orders CASCADE;

View File

@ -0,0 +1,5 @@
DROP FUNCTION Orders;
DROP TEMPORARY FUNCTION IF EXISTS Orders;
DROP TEMPORARY SYSTEM FUNCTION IF EXISTS Orders;

View File

@ -0,0 +1,5 @@
DROP TABLE Orders;
DROP TABLE IF EXISTS Orders;
DROP TEMPORARY TABLE IF EXISTS Orders;

View File

@ -0,0 +1,3 @@
DROP VIEW Orders;
DROP TEMPORARY VIEW IF EXISTS Orders;