fix: isolate integration test databases to prevent parallel teardown conflicts
Each integration test file now uses its own MongoDB database: - ttl_expiration → adam-acs-ttl-test - device_model → adam-acs-devices-test - base_model → adam-acs-basemodel-test Prevents dropDatabase() in one afterAll from destroying data used by another test file running concurrently. Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
This commit is contained in:
1 parent
b3142a8272
commit
ef30c2159c
3 files changed
+6
-6
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest'
|
||||
import { MongoClient, Db, ObjectId } from 'mongodb'
|
||||
|
||||
const MONGO_URI = 'mongodb://adam:adam@localhost:27017/adam-acs-test?authSource=admin'
|
||||
const MONGO_URI = 'mongodb://adam:adam@localhost:27017/adam-acs-basemodel-test?authSource=admin'
|
||||
let client: MongoClient
|
||||
let db: Db
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('BaseModel (integration)', () => {
|
||||
beforeAll(async () => {
|
||||
client = new MongoClient(MONGO_URI)
|
||||
await client.connect()
|
||||
db = client.db('adam-acs-test')
|
||||
db = client.db('adam-acs-basemodel-test')
|
||||
|
||||
// Patch getMongoDb for BaseModel
|
||||
const mod = await import('../../../providers/mongodb_provider.js')
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest'
|
||||
import { MongoClient, Db } from 'mongodb'
|
||||
import { DeviceId } from '../../../app/domain/device/device_id.js'
|
||||
|
||||
const MONGO_URI = 'mongodb://adam:adam@localhost:27017/adam-acs-test?authSource=admin'
|
||||
const MONGO_URI = 'mongodb://adam:adam@localhost:27017/adam-acs-devices-test?authSource=admin'
|
||||
let client: MongoClient
|
||||
let db: Db
|
||||
let skip = false
|
||||
@@ -12,7 +12,7 @@ describe('Device Model (integration)', () => {
|
||||
try {
|
||||
client = new MongoClient(MONGO_URI, { serverSelectionTimeoutMS: 2000 })
|
||||
await client.connect()
|
||||
db = client.db('adam-acs-test')
|
||||
db = client.db('adam-acs-devices-test')
|
||||
} catch {
|
||||
skip = true
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest'
|
||||
import { MongoClient, Db } from 'mongodb'
|
||||
|
||||
const MONGO_URI = 'mongodb://adam:adam@localhost:27017/adam-acs-test?authSource=admin'
|
||||
const MONGO_URI = 'mongodb://adam:adam@localhost:27017/adam-acs-ttl-test?authSource=admin'
|
||||
const COLLECTION_NAME = 'cwmp_exchanges'
|
||||
|
||||
let client: MongoClient
|
||||
@@ -13,7 +13,7 @@ describe('TTL expiration integration test', () => {
|
||||
try {
|
||||
client = new MongoClient(MONGO_URI, { serverSelectionTimeoutMS: 2000 })
|
||||
await client.connect()
|
||||
db = client.db('adam-acs-test')
|
||||
db = client.db('adam-acs-ttl-test')
|
||||
|
||||
// Ensure the collection exists before creating the index
|
||||
const collections = await db.listCollections({ name: COLLECTION_NAME }).toArray()
|
||||
|
||||
Reference in new issue
Block a user