From 206ce4265547b616a88fb03767db73800e42eace Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 19 Oct 2024 13:22:27 -0400 Subject: [PATCH] Destroy old db instance during subscription test when resetting db instance --- .gitea/workflows/test.yaml | 3 ++- api/data/database.ts | 3 ++- api/data/subscription.test.ts | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index c21b4fc..3d99d06 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -10,7 +10,8 @@ jobs: - uses: actions/checkout@v4 - name: Install docker uses: papodaca/install-docker-action@main - - env: NODE_OPTIONS=--max-old-space-size=8192 + - name: Run Tests + env: NODE_OPTIONS=--max-old-space-size=8192 run: | npm install npm run test diff --git a/api/data/database.ts b/api/data/database.ts index d66d137..94d3c8b 100644 --- a/api/data/database.ts +++ b/api/data/database.ts @@ -20,7 +20,8 @@ export let db = new Kysely({ dialect, }) -export function resetDbInstance() { +export async function resetDbInstance() { + await db.destroy() db = new Kysely({ dialect, }) diff --git a/api/data/subscription.test.ts b/api/data/subscription.test.ts index 0b6bbd2..bd06941 100644 --- a/api/data/subscription.test.ts +++ b/api/data/subscription.test.ts @@ -34,8 +34,8 @@ jest.mock("./settings", () => ({ })) describe("subscriptions", () => { - beforeAll(() => { - resetDbInstance() + beforeAll(async () => { + await resetDbInstance() }) beforeEach(async () => {