From 8ce4c0a7ceb48a904df8aa0d247ebb5ec67192e0 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 31 Oct 2024 15:04:34 +0100 Subject: [PATCH] test refactor --- .../__tests__/deploy-database.spec.js | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/integration-tests/__tests__/deploy-database.spec.js b/integration-tests/__tests__/deploy-database.spec.js index 222ff854..8fe809a4 100644 --- a/integration-tests/__tests__/deploy-database.spec.js +++ b/integration-tests/__tests__/deploy-database.spec.js @@ -70,8 +70,16 @@ function checkStructure( } async function testDatabaseDeploy(engine, conn, driver, dbModelsYaml, options) { - const { testEmptyLastScript, finalCheckAgainstModel, dbdiffOptionsExtra, allowDropStatements } = options || {}; + const { testEmptyLastScript, finalCheckAgainstModel, markDeleted, allowDropStatements } = options || {}; let index = 0; + const dbdiffOptionsExtra = markDeleted + ? { + deletedTablePrefix: '_deleted_', + deletedColumnPrefix: '_deleted_', + deletedSqlObjectPrefix: '_deleted_', + } + : {}; + for (const loadedDbModel of dbModelsYaml) { const { sql, isEmpty } = await generateDeploySql({ systemConnection: conn.isPreparedOnly ? undefined : conn, @@ -486,11 +494,7 @@ describe('Deploy database', () => { 'Mark table removed - %s', testWrapper(async (conn, driver, engine) => { await testDatabaseDeploy(engine, conn, driver, [[T1], [], []], { - dbdiffOptionsExtra: { - deletedTablePrefix: '_deleted_', - deletedColumnPrefix: '_deleted_', - deletedSqlObjectPrefix: '_deleted_', - }, + markDeleted: true, disallowExtraObjects: true, finalCheckAgainstModel: [T1_DELETED], }); @@ -501,11 +505,7 @@ describe('Deploy database', () => { 'Mark view removed - %s', testWrapper(async (conn, driver, engine) => { await testDatabaseDeploy(engine, conn, driver, [[T1, V1], [T1]], { - dbdiffOptionsExtra: { - deletedTablePrefix: '_deleted_', - deletedColumnPrefix: '_deleted_', - deletedSqlObjectPrefix: '_deleted_', - }, + markDeleted: true, disallowExtraObjects: true, finalCheckAgainstModel: [T1, V1_DELETED], }); @@ -516,11 +516,7 @@ describe('Deploy database', () => { 'Mark column removed - %s', testWrapper(async (conn, driver, engine) => { await testDatabaseDeploy(engine, conn, driver, [[T1], [T1_NO_VAL]], { - dbdiffOptionsExtra: { - deletedTablePrefix: '_deleted_', - deletedColumnPrefix: '_deleted_', - deletedSqlObjectPrefix: '_deleted_', - }, + markDeleted: true, disallowExtraObjects: true, finalCheckAgainstModel: [T1_DELETED_VAL], }); @@ -542,11 +538,7 @@ describe('Deploy database', () => { [T1], ], { - dbdiffOptionsExtra: { - deletedTablePrefix: '_deleted_', - deletedColumnPrefix: '_deleted_', - deletedSqlObjectPrefix: '_deleted_', - }, + markDeleted: true, disallowExtraObjects: true, } ); @@ -557,11 +549,7 @@ describe('Deploy database', () => { 'Undelete view - %s', testWrapper(async (conn, driver, engine) => { await testDatabaseDeploy(engine, conn, driver, [[T1, V1], [T1], [T1, V1]], { - dbdiffOptionsExtra: { - deletedTablePrefix: '_deleted_', - deletedColumnPrefix: '_deleted_', - deletedSqlObjectPrefix: '_deleted_', - }, + markDeleted: true, disallowExtraObjects: true, allowDropStatements: true, });