@@ -113,4 +113,43 @@ test.group('Lock', () => {
113113
114114 assert . deepEqual ( result , 'foo' )
115115 } )
116+
117+ test ( 'use default ttl when not specified' , async ( { assert } ) => {
118+ assert . plan ( 1 )
119+
120+ class FakeStore extends NullStore {
121+ async extend ( _key : string , _owner : string , duration : number ) {
122+ assert . deepEqual ( duration , 1000 )
123+ }
124+ }
125+
126+ const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { } , logger : noopLogger ( ) } , 'bar' , 1000 )
127+ await lock . extend ( )
128+ } )
129+
130+ test ( 'use specific ttl when specified' , async ( { assert } ) => {
131+ assert . plan ( 1 )
132+
133+ class FakeStore extends NullStore {
134+ async extend ( _key : string , _owner : string , duration : number ) {
135+ assert . deepEqual ( duration , 2000 )
136+ }
137+ }
138+
139+ const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { } , logger : noopLogger ( ) } , 'bar' , 1000 )
140+ await lock . extend ( 2000 )
141+ } )
142+
143+ test ( 'resolve string ttl' , async ( { assert } ) => {
144+ assert . plan ( 1 )
145+
146+ class FakeStore extends NullStore {
147+ async extend ( _key : string , _owner : string , duration : number ) {
148+ assert . deepEqual ( duration , 2000 )
149+ }
150+ }
151+
152+ const lock = new Lock ( 'foo' , new FakeStore ( ) , { retry : { } , logger : noopLogger ( ) } , 'bar' , 1000 )
153+ await lock . extend ( '2s' )
154+ } )
116155} )
0 commit comments