This commit is contained in:
Jan Prochazka
2021-05-27 13:50:49 +02:00
parent f360ba7187
commit d7e7b97fb8
2 changed files with 7 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ const initSql = ['CREATE TABLE t1 (id int)', 'CREATE TABLE t2 (id int)'];
function flatSource() {
return _.flatten(
engines.map(engine => (engine.objects || []).map(object => [engine.label, engine, object.type, object]))
engines.map(engine => (engine.objects || []).map(object => [engine.label, object.type, object, engine]))
);
}
@@ -18,7 +18,7 @@ const obj1Match = expect.objectContaining({
describe('Object analyse', () => {
test.each(flatSource())(
'Full analysis (%s - %s)',
testWrapper(async (conn, driver, engine, type, object) => {
testWrapper(async (conn, driver, type, object, engine) => {
for (const sql of initSql) await driver.query(conn, sql);
await driver.query(conn, object.create1);
@@ -31,7 +31,7 @@ describe('Object analyse', () => {
test.each(flatSource())(
'Incremental analysis - add (%s - %s)',
testWrapper(async (conn, driver, engine, type, object) => {
testWrapper(async (conn, driver, type, object, engine) => {
for (const sql of initSql) await driver.query(conn, sql);
await driver.query(conn, object.create2);
@@ -46,7 +46,7 @@ describe('Object analyse', () => {
test.each(flatSource())(
'Incremental analysis - drop (%s - %s)',
testWrapper(async (conn, driver, engine, type, object) => {
testWrapper(async (conn, driver, type, object, engine) => {
for (const sql of initSql) await driver.query(conn, sql);
await driver.query(conn, object.create1);

View File

@@ -44,11 +44,12 @@ async function connect(engine, database) {
}
}
const testWrapper = body => async (label, engine, ...other) => {
const testWrapper = body => async (label, ...other) => {
const engine = other[other.length - 1];
const driver = requireEngineDriver(engine.connection);
const conn = await connect(engine, randomDbName());
try {
await body(conn, driver, engine, ...other);
await body(conn, driver, ...other);
} finally {
await driver.close(conn);
}