From f93acc00de1755f594d2d0f79ed46fb0ac9a7ed4 Mon Sep 17 00:00:00 2001 From: hhow09 Date: Wed, 22 Jan 2025 15:57:45 +0100 Subject: [PATCH] fix: mongo in ci --- .github/workflows/ci.yaml | 7 ++++++- backend/src/repositories/chat-repo.spec.ts | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 834531c..4efef32 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,8 +14,13 @@ jobs: image: mongo:6.0.20 ports: - 27017:27017 + options: >- + --health-cmd "mongosh --eval 'db.runCommand(\"ping\")'" + --health-interval 10s + --health-timeout 5s + --health-retries 5 env: - MONGODB_URI: mongodb://mongo:27017 + MONGODB_URI: mongodb://localhost:27017 strategy: matrix: directory: [ "./backend" ] diff --git a/backend/src/repositories/chat-repo.spec.ts b/backend/src/repositories/chat-repo.spec.ts index 306634f..adb268c 100644 --- a/backend/src/repositories/chat-repo.spec.ts +++ b/backend/src/repositories/chat-repo.spec.ts @@ -10,11 +10,16 @@ describe("ChatRepo", () => { const clientId = "123"; const clientId2 = "456"; + jest.setTimeout(30000); + beforeAll(async () => { const uri: string = process.env.MONGODB_URI || "mongodb://localhost:27017"; client = new MongoClient(uri); + console.log("client", client); await client.connect(); + console.log("client connected"); testCollection = client.db("test").collection("chat-sessions"); + console.log("testCollection", testCollection); repo = new ChatRepo(testCollection); });