56 lines
2.4 KiB
JavaScript
56 lines
2.4 KiB
JavaScript
|
|
import fs from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
|
||
|
|
const root = path.resolve(import.meta.dirname, '..')
|
||
|
|
|
||
|
|
const files = {
|
||
|
|
page: path.join(root, 'index.vue'),
|
||
|
|
dialog: path.join(root, 'components/DbmsConnectionDialog.vue'),
|
||
|
|
taskPanel: path.join(root, 'components/DbmsTaskPanel.vue'),
|
||
|
|
payload: path.join(root, 'utils/taskPayload.ts'),
|
||
|
|
apiTypes: path.join(root, '../../../api/system/dbms/interface/index.ts')
|
||
|
|
}
|
||
|
|
|
||
|
|
const read = file => fs.readFileSync(file, 'utf8')
|
||
|
|
|
||
|
|
const checks = [
|
||
|
|
['connection list should not hardcode ORACLE dbType', !/dbType:\s*'ORACLE'/.test(read(files.page))],
|
||
|
|
['mysql entry should not be blocked in connection type selection', !/if\s*\(dbType\s*===\s*'MYSQL'\)/.test(read(files.page))],
|
||
|
|
['connection payload type should define databaseName', /databaseName\?:\s*string \| null/.test(read(files.apiTypes))],
|
||
|
|
['connection form model should define databaseName', /databaseName:\s*string/.test(read(files.payload))],
|
||
|
|
['payload builder should map MySQL databaseName', /databaseName:\s*dbType === 'MYSQL' \? form\.databaseName\.trim\(\) \|\| null : null/.test(read(files.payload))],
|
||
|
|
[
|
||
|
|
'backup file list should support MySQL JDBC_EXPORT strategy',
|
||
|
|
/backupStrategy:\s*backupStrategy \|\| undefined/.test(read(files.payload))
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'mysql backup payload should prefer databaseName as schemaName fallback',
|
||
|
|
/connection\.dbType === 'MYSQL'[\s\S]*connection\.databaseName[\s\S]*connection\.schemaName/.test(read(files.payload))
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'mysql task panel should lock backup strategy to JDBC_EXPORT',
|
||
|
|
/isMysqlConnection[\s\S]*backupForm\.backupStrategy = 'JDBC_EXPORT'/.test(read(files.taskPanel))
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'task panel should hide Data Pump Directory field',
|
||
|
|
!/label="Directory"[\s\S]*v-model="backupForm\.directoryName"/.test(read(files.taskPanel))
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'mysql task panel should label schema input as database name',
|
||
|
|
/:label="schemaFieldLabel"/.test(read(files.taskPanel))
|
||
|
|
],
|
||
|
|
['connection dialog should render databaseName field for MySQL', /v-if="selectedDbType === 'MYSQL'"/.test(read(files.dialog))]
|
||
|
|
]
|
||
|
|
|
||
|
|
const failed = checks.filter(([, passed]) => !passed)
|
||
|
|
|
||
|
|
if (failed.length) {
|
||
|
|
console.error('dbms mysql api debug contract failed:')
|
||
|
|
for (const [message] of failed) {
|
||
|
|
console.error(`- ${message}`)
|
||
|
|
}
|
||
|
|
process.exit(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log('dbms mysql api debug contract passed')
|