File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -219,4 +219,31 @@ describe("HiLo", function () {
219219 assert . ok ( parseInt ( numericPart , 10 ) < 33 ) ;
220220 } ) ;
221221 } ) ;
222+
223+ it ( "does get another range when gets over max and leaves no gaps" , async ( ) => {
224+ const parallelLevel = 40 ;
225+ const users = Array . from ( Array ( parallelLevel ) . keys ( ) ) . map ( x => new User ( ) ) ;
226+
227+ const tasks = Array . from ( Array ( parallelLevel ) . keys ( ) ) . map ( async i => {
228+ const user = users [ i ] ;
229+ const session = store . openSession ( ) ;
230+ await session . store ( user ) ;
231+ await session . saveChanges ( ) ;
232+ } ) ;
233+
234+ await Promise . all ( tasks ) ;
235+
236+ const idNumbers = users
237+ . map ( x => x . id )
238+ . map ( id => id . split ( "/" ) [ 1 ] )
239+ . map ( x => parseInt ( x . split ( "-" ) [ 0 ] , 10 ) ) ;
240+
241+ assert . strictEqual ( idNumbers . length , 40 ) ;
242+
243+ idNumbers . sort ( ( a , b ) => a > b ? 1 : - 1 ) ;
244+
245+ for ( let i = 1 ; i <= 40 ; i ++ ) {
246+ assert . strictEqual ( idNumbers [ i - 1 ] , i ) ;
247+ }
248+ } ) ;
222249} ) ;
You can’t perform that action at this time.
0 commit comments