mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
columns cross-tests
This commit is contained in:
parent
331b275105
commit
7a2e86246d
@ -51,6 +51,12 @@ async function testTableDiff(conn, driver, mangle) {
|
|||||||
// expect(stableStringify(structure2)).toEqual(stableStringify(structure2Real));
|
// expect(stableStringify(structure2)).toEqual(stableStringify(structure2Real));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function engines_columns_source() {
|
||||||
|
return _.flatten(
|
||||||
|
engines.map(engine => ['col_std', 'col_def', 'col_fk', 'col_idx'].map(column => [engine.label, column, engine]))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
describe('Alter processor', () => {
|
describe('Alter processor', () => {
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
'Add column - %s',
|
'Add column - %s',
|
||||||
@ -67,41 +73,31 @@ describe('Alter processor', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
test.each(engines_columns_source())(
|
||||||
'Drop column - %s',
|
'Drop column - %s - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, column, engine) => {
|
||||||
await testTableDiff(conn, driver, tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != 'col_std')));
|
await testTableDiff(conn, driver, tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != column)));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
test.each(engines_columns_source())(
|
||||||
'Drop column with default - %s',
|
'Change nullability - %s - %s',
|
||||||
testWrapper(async (conn, driver, engine) => {
|
testWrapper(async (conn, driver, column, engine) => {
|
||||||
await testTableDiff(conn, driver, tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != 'col_def')));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
|
||||||
'Drop column with fk - %s',
|
|
||||||
testWrapper(async (conn, driver, engine) => {
|
|
||||||
await testTableDiff(conn, driver, tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != 'col_fk')));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
|
||||||
'Drop column with index - %s',
|
|
||||||
testWrapper(async (conn, driver, engine) => {
|
|
||||||
await testTableDiff(conn, driver, tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != 'col_idx')));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
test.each(engines.map(engine => [engine.label, engine]))(
|
|
||||||
'Change nullability - %s',
|
|
||||||
testWrapper(async (conn, driver, engine) => {
|
|
||||||
await testTableDiff(
|
await testTableDiff(
|
||||||
conn,
|
conn,
|
||||||
driver,
|
driver,
|
||||||
tbl => (tbl.columns = tbl.columns.map(x => (x.columnName == 'col_std' ? { ...x, notNull: true } : x)))
|
tbl => (tbl.columns = tbl.columns.map(x => (x.columnName == column ? { ...x, notNull: true } : x)))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
test.each(engines_columns_source())(
|
||||||
|
'Rename column - %s',
|
||||||
|
testWrapper(async (conn, driver, column, engine) => {
|
||||||
|
await testTableDiff(
|
||||||
|
conn,
|
||||||
|
driver,
|
||||||
|
tbl => (tbl.columns = tbl.columns.map(x => (x.columnName == column ? { ...x, columnName: 'col_renamed' } : x)))
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user