2024-03-27 10:33:25 +08:00
|
|
|
import { MySQL } from 'src/parser/mysql';
|
2024-01-19 21:10:00 +08:00
|
|
|
import { readSQL } from 'test/helper';
|
2023-11-27 15:25:40 +08:00
|
|
|
|
2024-03-27 10:33:25 +08:00
|
|
|
const mysql = new MySQL();
|
2023-11-27 15:25:40 +08:00
|
|
|
|
|
|
|
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, () => {
|
2024-03-27 10:33:25 +08:00
|
|
|
const result = mysql.validate(sql);
|
2023-11-27 15:25:40 +08:00
|
|
|
if (result.length) {
|
2024-02-26 20:25:09 +08:00
|
|
|
console.error(result, `\nPlease check sql: ${sql}`);
|
2023-11-27 15:25:40 +08:00
|
|
|
}
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|