lava-oushudb-dt-sql-parser/test/parser/mysql/syntax/administration.test.ts
Hayden 8f72a5af60
Fix/export abstract visitor (#237)
* fix: #236 export AbstractParseTreeVisitor

* build: set isolatedModules true

* feat: import parser about from filters
2023-12-19 19:22:27 +08:00

52 lines
2.2 KiB
TypeScript

import { MySQL } from '../../../filters';
import { readSQL } from '../../../helper';
const parser = new MySQL();
const features = {
alterUser: readSQL(__dirname, 'alterUser.sql'),
createRole: readSQL(__dirname, 'createRole.sql'),
createUser: readSQL(__dirname, 'createUser.sql'),
dropRole: readSQL(__dirname, 'dropRole.sql'),
dropUser: readSQL(__dirname, 'dropUser.sql'),
grant: readSQL(__dirname, 'grant.sql'),
renameUser: readSQL(__dirname, 'renameUser.sql'),
revoke: readSQL(__dirname, 'revoke.sql'),
setDefaultRole: readSQL(__dirname, 'setDefaultRole.sql'),
setPassword: readSQL(__dirname, 'setPassword.sql'),
setRole: readSQL(__dirname, 'setRole.sql'),
alterResourceGroup: readSQL(__dirname, 'alterResourceGroup.sql'),
createResourceGroup: readSQL(__dirname, 'createResourceGroup.sql'),
dropResourceGroup: readSQL(__dirname, 'dropResourceGroup.sql'),
setResourceGroup: readSQL(__dirname, 'setResourceGroup.sql'),
analyzeTable: readSQL(__dirname, 'analyzeTable.sql'),
checkTable: readSQL(__dirname, 'checkTable.sql'),
checkSumTable: readSQL(__dirname, 'checkSumTable.sql'),
optimizeTable: readSQL(__dirname, 'optimizeTable.sql'),
repairTable: readSQL(__dirname, 'repairTable.sql'),
installComponent: readSQL(__dirname, 'installComponent.sql'),
installPlugin: readSQL(__dirname, 'installPlugin.sql'),
uninstallComponent: readSQL(__dirname, 'uninstallComponent.sql'),
uninstallPlugin: readSQL(__dirname, 'uninstallPlugin.sql'),
clone: readSQL(__dirname, 'clone.sql'),
set: readSQL(__dirname, 'set.sql'),
setCharacterSet: readSQL(__dirname, 'setCharacterSet.sql'),
setNames: readSQL(__dirname, 'setNames.sql'),
show: readSQL(__dirname, 'show.sql'),
otherAdministrative: readSQL(__dirname, 'otherAdministrative.sql'),
};
describe('MySQL Database Administration Syntax Tests', () => {
Object.keys(features).forEach((key) => {
features[key].forEach((sql) => {
it(sql, () => {
const result = parser.validate(sql);
if (result.length) {
console.log(result, `\nPlease check sql: ${sql}`);
}
expect(result.length).toBe(0);
});
});
});
});