mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Move integration test utils for insights (#16693)
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
import 'tsconfig-paths/register';
|
||||
import { testDb } from '@n8n/backend-test-utils';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Container } from '@n8n/di';
|
||||
import { DataSource as Connection } from '@n8n/typeorm';
|
||||
|
||||
import { getBootstrapDBOptions, testDbPrefix } from './integration/shared/test-db';
|
||||
|
||||
export default async () => {
|
||||
const { type: dbType } = Container.get(GlobalConfig).database;
|
||||
if (dbType !== 'postgresdb' && dbType !== 'mysqldb') return;
|
||||
|
||||
const connection = new Connection(getBootstrapDBOptions(dbType));
|
||||
const connection = new Connection(testDb.getBootstrapDBOptions(dbType));
|
||||
await connection.initialize();
|
||||
|
||||
const query =
|
||||
dbType === 'postgresdb' ? 'SELECT datname as "Database" FROM pg_database' : 'SHOW DATABASES';
|
||||
const results: Array<{ Database: string }> = await connection.query(query);
|
||||
const databases = results
|
||||
.filter(({ Database: dbName }) => dbName.startsWith(testDbPrefix))
|
||||
.filter(({ Database: dbName }) => dbName.startsWith(testDb.testDbPrefix))
|
||||
.map(({ Database: dbName }) => dbName);
|
||||
|
||||
const promises = databases.map(
|
||||
|
||||
Reference in New Issue
Block a user