mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 20:43:58 +00:00
alter table - flat tests
This commit is contained in:
@@ -90,7 +90,7 @@ const TESTED_COLUMNS = ['col_pk', 'col_std', 'col_def', 'col_fk', 'col_ref', 'co
|
|||||||
// const TESTED_COLUMNS = ['col_std'];
|
// const TESTED_COLUMNS = ['col_std'];
|
||||||
// const TESTED_COLUMNS = ['col_ref'];
|
// const TESTED_COLUMNS = ['col_ref'];
|
||||||
|
|
||||||
function create_engines_columns_source(engines) {
|
function createEnginesColumnsSource(engines) {
|
||||||
return _.flatten(
|
return _.flatten(
|
||||||
engines.map(engine =>
|
engines.map(engine =>
|
||||||
TESTED_COLUMNS.filter(col => col.endsWith('_pk') || !engine.skipNonPkRename)
|
TESTED_COLUMNS.filter(col => col.endsWith('_pk') || !engine.skipNonPkRename)
|
||||||
@@ -116,32 +116,16 @@ describe('Alter table', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const columnsSource = create_engines_columns_source(engines);
|
test.each(
|
||||||
const dropableColumnsSrouce = columnsSource.filter(
|
createEnginesColumnsSource(engines).filter(([_label, col, engine]) => !engine.skipPkDrop || !col.endsWith('_pk'))
|
||||||
([_label, col, engine]) => !engine.skipPkDrop || !col.endsWith('_pk')
|
)(
|
||||||
);
|
|
||||||
const hasDropableColumns = dropableColumnsSrouce.length > 0;
|
|
||||||
|
|
||||||
if (hasDropableColumns) {
|
|
||||||
test.each(dropableColumnsSrouce)(
|
|
||||||
'Drop column - %s - %s',
|
'Drop column - %s - %s',
|
||||||
testWrapper(async (conn, driver, column, engine) => {
|
testWrapper(async (conn, driver, column, engine) => {
|
||||||
await testTableDiff(
|
await testTableDiff(engine, conn, driver, tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != column)));
|
||||||
engine,
|
|
||||||
conn,
|
|
||||||
driver,
|
|
||||||
tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != column))
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const hasEnginesWithNullable = engines.filter(x => !x.skipNullable).length > 0;
|
test.each(createEnginesColumnsSource(engines.filter(x => !x.skipNullable)))(
|
||||||
|
|
||||||
if (hasEnginesWithNullable) {
|
|
||||||
const source = create_engines_columns_source(engines.filter(x => !x.skipNullable));
|
|
||||||
|
|
||||||
test.each(source)(
|
|
||||||
'Change nullability - %s - %s',
|
'Change nullability - %s - %s',
|
||||||
testWrapper(async (conn, driver, column, engine) => {
|
testWrapper(async (conn, driver, column, engine) => {
|
||||||
await testTableDiff(
|
await testTableDiff(
|
||||||
@@ -152,9 +136,8 @@ describe('Alter table', () => {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
test.each(columnsSource)(
|
test.each(createEnginesColumnsSource(engines))(
|
||||||
'Rename column - %s - %s',
|
'Rename column - %s - %s',
|
||||||
testWrapper(async (conn, driver, column, engine) => {
|
testWrapper(async (conn, driver, column, engine) => {
|
||||||
await testTableDiff(
|
await testTableDiff(
|
||||||
@@ -175,11 +158,7 @@ describe('Alter table', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const enginesWithDefault = engines.filter(x => !x.skipDefaultValue);
|
test.each(engines.filter(x => !x.skipDefaultValue).map(engine => [engine.label, engine]))(
|
||||||
const hasEnginesWithDefault = enginesWithDefault.length > 0;
|
|
||||||
|
|
||||||
if (hasEnginesWithDefault) {
|
|
||||||
test.each(enginesWithDefault.map(engine => [engine.label, engine]))(
|
|
||||||
'Add default value - %s',
|
'Add default value - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
await testTableDiff(engine, conn, driver, tbl => {
|
await testTableDiff(engine, conn, driver, tbl => {
|
||||||
@@ -188,7 +167,7 @@ describe('Alter table', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
test.each(enginesWithDefault.map(engine => [engine.label, engine]))(
|
test.each(engines.filter(x => !x.skipDefaultValue).map(engine => [engine.label, engine]))(
|
||||||
'Unset default value - %s',
|
'Unset default value - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
await testTableDiff(engine, conn, driver, tbl => {
|
await testTableDiff(engine, conn, driver, tbl => {
|
||||||
@@ -197,7 +176,7 @@ describe('Alter table', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
test.each(enginesWithDefault.map(engine => [engine.label, engine]))(
|
test.each(engines.filter(x => !x.skipDefaultValue).map(engine => [engine.label, engine]))(
|
||||||
'Change default value - %s',
|
'Change default value - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, engine) => {
|
||||||
await testTableDiff(engine, conn, driver, tbl => {
|
await testTableDiff(engine, conn, driver, tbl => {
|
||||||
@@ -205,7 +184,6 @@ describe('Alter table', () => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// test.each(engines.map(engine => [engine.label, engine]))(
|
// test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
// 'Change autoincrement - %s',
|
// 'Change autoincrement - %s',
|
||||||
|
|||||||
Reference in New Issue
Block a user