From 3c31643e8308cc63b721702b6a51a27a97aa9add Mon Sep 17 00:00:00 2001 From: Visal In Date: Wed, 18 Dec 2024 19:58:46 +0800 Subject: [PATCH] add force exist jest --- package.json | 2 +- src/connections/mysql.ts | 38 ++++++++++++++-------------- tests/connections/connection.test.ts | 2 +- tests/connections/postgres.test.ts | 2 ++ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 5f85f20..dcdcc92 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "prepack": "npm run build", "prepare": "husky install", "test": "jest --verbose --testPathPattern=unit", - "test:connection": "jest --verbose --testPathPattern=connection --runInBand", + "test:connection": "jest --verbose --testPathPattern=connection --runInBand --forceExit", "test:watch": "jest --watch", "test:coverage": "jest --coverage --testPathPattern=unit" }, diff --git a/src/connections/mysql.ts b/src/connections/mysql.ts index 33321b4..0882de5 100644 --- a/src/connections/mysql.ts +++ b/src/connections/mysql.ts @@ -127,10 +127,10 @@ export function buildMySQLDatabaseSchmea({ columnLookup[ column.TABLE_SCHEMA + - '.' + - column.TABLE_NAME + - '.' + - column.COLUMN_NAME + '.' + + column.TABLE_NAME + + '.' + + column.COLUMN_NAME ] = columnObject; table.columns.push(columnObject); @@ -156,10 +156,10 @@ export function buildMySQLDatabaseSchmea({ constraintLookup[ constraint.TABLE_SCHEMA + - '.' + - constraint.TABLE_NAME + - '.' + - constraint.CONSTRAINT_NAME + '.' + + constraint.TABLE_NAME + + '.' + + constraint.CONSTRAINT_NAME ] = constraintObject; table.constraints.push(constraintObject); @@ -169,22 +169,22 @@ export function buildMySQLDatabaseSchmea({ for (const constraintColumn of constraintColumnsList) { const constraint = constraintLookup[ - constraintColumn.TABLE_SCHEMA + - '.' + - constraintColumn.TABLE_NAME + - '.' + - constraintColumn.CONSTRAINT_NAME + constraintColumn.TABLE_SCHEMA + + '.' + + constraintColumn.TABLE_NAME + + '.' + + constraintColumn.CONSTRAINT_NAME ]; if (!constraint) continue; const currentColumn = columnLookup[ - constraintColumn.TABLE_SCHEMA + - '.' + - constraintColumn.TABLE_NAME + - '.' + - constraintColumn.COLUMN_NAME + constraintColumn.TABLE_SCHEMA + + '.' + + constraintColumn.TABLE_NAME + + '.' + + constraintColumn.COLUMN_NAME ]; if (currentColumn && constraintColumn.REFERENCED_COLUMN_NAME) { currentColumn.definition.references = { @@ -377,7 +377,7 @@ export class MySQLConnection extends SqlConnection { ); } - async connect(): Promise {} + async connect(): Promise { } async disconnect(): Promise { this.conn.destroy(); } diff --git a/tests/connections/connection.test.ts b/tests/connections/connection.test.ts index 4b14a97..ba546b2 100644 --- a/tests/connections/connection.test.ts +++ b/tests/connections/connection.test.ts @@ -10,7 +10,7 @@ beforeAll(async () => { // Clean up all tables const schemaList = await db.fetchDatabaseSchema(); - const currentSchema = schemaList[DEFAULT_SCHEMA]; + const currentSchema = schemaList[DEFAULT_SCHEMA] ?? {}; for (const table of Object.values(currentSchema)) { await db.dropTable(DEFAULT_SCHEMA, table.name) diff --git a/tests/connections/postgres.test.ts b/tests/connections/postgres.test.ts index 1a86d78..6c66e01 100644 --- a/tests/connections/postgres.test.ts +++ b/tests/connections/postgres.test.ts @@ -2,10 +2,12 @@ import createTestClient from './create-test-connection'; const { client: db, defaultSchema: DEFAULT_SCHEMA } = createTestClient(); beforeAll(async () => { + if (process.env.CONNECTION_TYPE !== 'postgres') return; await db.connect(); }); afterAll(async () => { + if (process.env.CONNECTION_TYPE !== 'postgres') return; await db.disconnect(); });