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