mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 23:05:59 +00:00
create table test
This commit is contained in:
41
integration-tests/__tests__/table-create.spec.js
Normal file
41
integration-tests/__tests__/table-create.spec.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const engines = require('../engines');
|
||||
const { testWrapper, checkTableStructure } = require('../tools');
|
||||
const { extendDatabaseInfo } = require('dbgate-tools');
|
||||
|
||||
async function testTableCreate(conn, driver, table) {
|
||||
const dmp = driver.createDumper();
|
||||
const table1 = {
|
||||
...table,
|
||||
pureName: 'tested',
|
||||
};
|
||||
dmp.createTable(table1);
|
||||
|
||||
console.log('RUNNING CREATE SQL', driver.engine, ':', dmp.s);
|
||||
await driver.query(conn, dmp.s);
|
||||
|
||||
const db = extendDatabaseInfo(await driver.analyseFull(conn));
|
||||
const table2 = db.tables.find(x => x.pureName == 'tested');
|
||||
|
||||
checkTableStructure(table1, table2);
|
||||
}
|
||||
|
||||
describe('Table create', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Table structure - full analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await testTableCreate(conn, driver, {
|
||||
columns: [
|
||||
{
|
||||
columnName: 'col1',
|
||||
dataType: 'int',
|
||||
notNull: true,
|
||||
autoIncrement: false,
|
||||
},
|
||||
],
|
||||
primaryKey: {
|
||||
columns: [{ columnName: 'col1' }],
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user