Skip to content

Commit 5880ea7

Browse files
committed
fix: tests
1 parent e9c5fd9 commit 5880ea7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/lib/migrations/migrations.spec.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterEach, assert, describe, expect, it } from "vitest";
1+
import { afterEach, assert, beforeAll, describe, expect, it } from "vitest";
22
import { migrations } from "./routines";
33
import { acquireLock, isDBLocked, refreshLock, releaseLock } from "./lock";
44
import { Semaphores } from "$lib/types/Semaphore";
@@ -10,6 +10,14 @@ describe(
1010
retry: 3,
1111
},
1212
() => {
13+
beforeAll(async () => {
14+
try {
15+
await collections.semaphores.createIndex({ key: 1 }, { unique: true });
16+
} catch (e) {
17+
// Index might already exist, ignore error
18+
}
19+
});
20+
1321
it("should not have duplicates guid", async () => {
1422
const guids = migrations.map((m) => m._id.toString());
1523
const uniqueGuids = [...new Set(guids)];
@@ -56,10 +64,10 @@ describe(
5664
expect(updatedAtAfterRefresh).toBeDefined();
5765
expect(updatedAtInitially).not.toBe(updatedAtAfterRefresh);
5866
});
67+
68+
afterEach(async () => {
69+
await collections.semaphores.deleteMany({});
70+
await collections.migrationResults.deleteMany({});
71+
});
5972
}
6073
);
61-
62-
afterEach(async () => {
63-
await collections.semaphores.deleteMany({});
64-
await collections.migrationResults.deleteMany({});
65-
});

0 commit comments

Comments
 (0)