refactor: import readSQL function

This commit is contained in:
wewoor 2023-05-11 18:12:50 +08:00
parent b39825e31a
commit 04a56ba618

View File

@ -1,22 +1,14 @@
import FlinkSQL from '../../../../src/parser/flinksql'; import FlinkSQL from '../../../../src/parser/flinksql';
import fs from 'fs'; import { readSQL } from '../../../helper';
import path from 'path';
const parser = new FlinkSQL(); const parser = new FlinkSQL();
const readSQL = (fileName: string) =>
fs
.readFileSync(path.join(__dirname, 'fixtures', fileName), 'utf-8')
.split(';')
.filter(Boolean)
.map((i) => i.trim());
const features = { const features = {
table: readSQL('createTable.sql'), table: readSQL(__dirname, 'createTable.sql'),
catalog: readSQL('createCatalog.sql'), catalog: readSQL(__dirname, 'createCatalog.sql'),
database: readSQL('createDatabase.sql'), database: readSQL(__dirname, 'createDatabase.sql'),
view: readSQL('createView.sql'), view: readSQL(__dirname, 'createView.sql'),
function: readSQL('createFunction.sql'), function: readSQL(__dirname, 'createFunction.sql'),
}; };
describe('FlinkSQL Create Syntax Tests', () => { describe('FlinkSQL Create Syntax Tests', () => {