1
0
Fork 0
mirror of synced 2024-07-09 00:06:05 +12:00

Correct the lock path.

This commit is contained in:
Sam Rose 2024-04-03 12:11:28 +01:00
parent dda0d1fb5b
commit b25912bc5e
No known key found for this signature in database

View file

@ -1,13 +1,15 @@
import { GenericContainer, Wait } from "testcontainers" import { GenericContainer, Wait } from "testcontainers"
import path from "path"
import lockfile from "proper-lockfile" import lockfile from "proper-lockfile"
export default async function setup() { export default async function setup() {
const lockPath = path.resolve(__dirname, "globalSetup.ts")
if (process.env.REUSE_CONTAINERS) { if (process.env.REUSE_CONTAINERS) {
// If you run multiple tests at the same time, it's possible for the CouchDB // If you run multiple tests at the same time, it's possible for the CouchDB
// shared container to get started multiple times despite having an // shared container to get started multiple times despite having an
// identical reuse hash. To avoid that, we do a filesystem-based lock so // identical reuse hash. To avoid that, we do a filesystem-based lock so
// that only one globalSetup.ts is running at a time. // that only one globalSetup.ts is running at a time.
lockfile.lockSync("globalSetup.lock") lockfile.lockSync(lockPath)
} }
try { try {
@ -45,7 +47,7 @@ export default async function setup() {
await couchdb.start() await couchdb.start()
} finally { } finally {
if (process.env.REUSE_CONTAINERS) { if (process.env.REUSE_CONTAINERS) {
lockfile.unlockSync("globalSetup.lock") lockfile.unlockSync(lockPath)
} }
} }
} }