From 69194597ee4788db9eb59865e31a79ac87d5c739 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Wed, 20 Nov 2024 09:58:33 -0800 Subject: [PATCH] [TM-1452] Workaround for test DB setup failures. --- setup-jest.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/setup-jest.ts b/setup-jest.ts index 37f6084..371ad9a 100644 --- a/setup-jest.ts +++ b/setup-jest.ts @@ -1,23 +1,29 @@ -import { Sequelize } from 'sequelize-typescript'; -import { FactoryGirl, SequelizeAdapter } from 'factory-girl-ts'; -import * as Entities from '@terramatch-microservices/database/entities'; +import { Sequelize } from "sequelize-typescript"; +import { FactoryGirl, SequelizeAdapter } from "factory-girl-ts"; +import * as Entities from "@terramatch-microservices/database/entities"; let sequelize: Sequelize; beforeAll(async () => { // To create this database, run the ./setup-test-database.sh script. sequelize = new Sequelize({ - dialect: 'mariadb', - host: 'localhost', + dialect: "mariadb", + host: "localhost", port: 3360, - username: 'wri', - password: 'wri', - database: 'terramatch_microservices_test', + username: "wri", + password: "wri", + database: "terramatch_microservices_test", models: Object.values(Entities), - logging: false, - }) + logging: false + }); - await sequelize.sync(); + try { + await sequelize.sync(); + } catch (e) { + // We can ignore this in most cases because it probably means another task has already synced + // the DB + console.info("Error Synchronizing DB Schema", e); + } FactoryGirl.setAdapter(new SequelizeAdapter()); });