Skip to content

Commit 6a58f91

Browse files
committed
fix: ci env mismatch of mongo url service for tests
1 parent 2b62d7c commit 6a58f91

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
jobs:
1010
backend-tests:
1111
runs-on: ubuntu-latest
12+
services:
13+
mongodb:
14+
image: mongo:latest
15+
ports:
16+
- 27017:27017
1217
steps:
1318
- uses: actions/checkout@v4
1419
- name: Setup Node.js
@@ -26,7 +31,7 @@ jobs:
2631
env:
2732
NODE_ENV: test
2833
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
29-
TEST_MONGO_URL: ${{ secrets.MONGO_URL_TEST }}
34+
TEST_MONGO_URL: mongodb://localhost:27017/test_db
3035
JWT_SECRET: ${{ secrets.JWT_SECRET }}
3136
SUPABASE_URL: "https://dummy.supabase.co"
3237
SUPABASE_KEY: "dummy-key"

backend/tests/auth.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ require('dotenv').config();
2020

2121
// --- SETUP
2222
beforeAll(async () => {
23-
// Connect to the TEST Database
2423
const uri = process.env.TEST_MONGO_URL;
25-
if (!uri) {
26-
throw new Error("TEST_MONGO_URL not defined in .env");
24+
25+
// Debugging (Secret is masked as *** in GitHub logs, but we can check the format)
26+
console.log("URI Length:", uri ? uri.length : 0);
27+
console.log("URI Starts with mongodb:", uri ? uri.startsWith('mongodb') : false);
28+
29+
if (!uri || !uri.startsWith('mongodb')) {
30+
throw new Error(`Invalid TEST_MONGO_URL! Received: ${uri ? 'invalid format' : 'nothing'}`);
2731
}
2832

2933
await mongoose.disconnect();

0 commit comments

Comments
 (0)