11import { test } from '@japa/runner'
2+ import { noopLogger } from 'typescript-log'
23
34import { Lock } from '../src/lock.js'
45import { E_LOCK_TIMEOUT } from '../src/errors.js'
@@ -8,7 +9,7 @@ import { NullStore } from '../test_helpers/null_store.js'
89test . group ( 'Lock' , ( ) => {
910 test ( 'acquire' , async ( { assert } ) => {
1011 const store = new MemoryStore ( )
11- const lock = new Lock ( 'foo' , store )
12+ const lock = new Lock ( 'foo' , store , { retry : { } , logger : noopLogger ( ) } )
1213
1314 assert . deepEqual ( await lock . isLocked ( ) , false )
1415
@@ -24,7 +25,10 @@ test.group('Lock', () => {
2425 }
2526 }
2627
27- const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { attempts : 2 , delay : 10 } } )
28+ const lock = new Lock ( 'foo' , new FakeStore ( ) , {
29+ retry : { attempts : 2 , delay : 10 } ,
30+ logger : noopLogger ( ) ,
31+ } )
2832
2933 // @ts -ignore
3034 await assert . rejects ( ( ) => lock . acquire ( ) , E_LOCK_TIMEOUT . message )
@@ -39,7 +43,7 @@ test.group('Lock', () => {
3943 }
4044 }
4145
42- const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { attempts : 5 } } )
46+ const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { attempts : 5 } , logger : noopLogger ( ) } )
4347
4448 // @ts -ignore
4549 await assert . rejects ( ( ) => lock . acquire ( ) , E_LOCK_TIMEOUT . message )
@@ -54,7 +58,10 @@ test.group('Lock', () => {
5458 }
5559
5660 const start = Date . now ( )
57- const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { attempts : 5 , delay : 100 } } )
61+ const lock = new Lock ( 'foo' , new FakeStore ( ) , {
62+ retry : { attempts : 5 , delay : 100 } ,
63+ logger : noopLogger ( ) ,
64+ } )
5865
5966 // @ts -ignore
6067 await assert . rejects ( ( ) => lock . acquire ( ) , E_LOCK_TIMEOUT . message )
@@ -71,7 +78,10 @@ test.group('Lock', () => {
7178 }
7279
7380 const start = Date . now ( )
74- const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { timeout : 100 , delay : 10 } } )
81+ const lock = new Lock ( 'foo' , new FakeStore ( ) , {
82+ retry : { timeout : 100 , delay : 10 } ,
83+ logger : noopLogger ( ) ,
84+ } )
7585
7686 // @ts -ignore
7787 await assert . rejects ( ( ) => lock . acquire ( ) , E_LOCK_TIMEOUT . message )
@@ -84,7 +94,7 @@ test.group('Lock', () => {
8494 assert . plan ( 3 )
8595
8696 const store = new MemoryStore ( )
87- const lock = new Lock ( 'foo' , store )
97+ const lock = new Lock ( 'foo' , store , { retry : { } , logger : noopLogger ( ) } )
8898
8999 assert . deepEqual ( await lock . isLocked ( ) , false )
90100
@@ -97,7 +107,7 @@ test.group('Lock', () => {
97107
98108 test ( 'run should return callback result' , async ( { assert } ) => {
99109 const store = new MemoryStore ( )
100- const lock = new Lock ( 'foo' , store )
110+ const lock = new Lock ( 'foo' , store , { retry : { } , logger : noopLogger ( ) } )
101111
102112 const result = await lock . run ( async ( ) => 'foo' )
103113
0 commit comments