Spaces:
Sleeping
Sleeping
fix: tests
Browse files
src/lib/migrations/migrations.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { afterEach, assert, describe, expect, it } from "vitest";
|
| 2 |
import { migrations } from "./routines";
|
| 3 |
import { acquireLock, isDBLocked, refreshLock, releaseLock } from "./lock";
|
| 4 |
import { Semaphores } from "$lib/types/Semaphore";
|
|
@@ -10,6 +10,14 @@ describe(
|
|
| 10 |
retry: 3,
|
| 11 |
},
|
| 12 |
() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
it("should not have duplicates guid", async () => {
|
| 14 |
const guids = migrations.map((m) => m._id.toString());
|
| 15 |
const uniqueGuids = [...new Set(guids)];
|
|
@@ -56,10 +64,10 @@ describe(
|
|
| 56 |
expect(updatedAtAfterRefresh).toBeDefined();
|
| 57 |
expect(updatedAtInitially).not.toBe(updatedAtAfterRefresh);
|
| 58 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
);
|
| 61 |
-
|
| 62 |
-
afterEach(async () => {
|
| 63 |
-
await collections.semaphores.deleteMany({});
|
| 64 |
-
await collections.migrationResults.deleteMany({});
|
| 65 |
-
});
|
|
|
|
| 1 |
+
import { afterEach, assert, beforeAll, describe, expect, it } from "vitest";
|
| 2 |
import { migrations } from "./routines";
|
| 3 |
import { acquireLock, isDBLocked, refreshLock, releaseLock } from "./lock";
|
| 4 |
import { Semaphores } from "$lib/types/Semaphore";
|
|
|
|
| 10 |
retry: 3,
|
| 11 |
},
|
| 12 |
() => {
|
| 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 |
+
|
| 21 |
it("should not have duplicates guid", async () => {
|
| 22 |
const guids = migrations.map((m) => m._id.toString());
|
| 23 |
const uniqueGuids = [...new Set(guids)];
|
|
|
|
| 64 |
expect(updatedAtAfterRefresh).toBeDefined();
|
| 65 |
expect(updatedAtInitially).not.toBe(updatedAtAfterRefresh);
|
| 66 |
});
|
| 67 |
+
|
| 68 |
+
afterEach(async () => {
|
| 69 |
+
await collections.semaphores.deleteMany({});
|
| 70 |
+
await collections.migrationResults.deleteMany({});
|
| 71 |
+
});
|
| 72 |
}
|
| 73 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|