@@ -619,43 +619,7 @@ export function registerBaseTests() {
619619 expect ( duration ) . lessThan ( 2000 ) ;
620620 } ) ;
621621
622- it ( 'Should handle multiple closes' , async ( ) => {
623- // Bulk insert 10000 rows without using a transaction
624- const bulkInsertCommands = [ ] ;
625- const statement = `INSERT INTO t1(id, c) VALUES(uuid(), ?)` ;
626-
627- for ( let i = 0 ; i < 10000 ; i ++ ) {
628- bulkInsertCommands . push ( [ [ `value${ i + 1 } ` ] ] ) ;
629- }
630-
631- await db . executeBatch ( statement , bulkInsertCommands ) ;
632- await db . close ( ) ;
633-
634- for ( let i = 1 ; i < 10 ; i ++ ) {
635- db = createDatabase ( ) ;
636- await db . init ( ) ;
637-
638- // ensure a regular query works
639- const pExecute = await db . execute ( `SELECT * FROM t1 ` ) ;
640- expect ( pExecute . rows ?. length ) . to . equal ( 10000 ) ;
641-
642- // Queue a bunch of write locks, these will fail due to the db being closed
643- // before they are accepted.
644- const tests = [
645- db . execute ( `SELECT * FROM t1 ` ) ,
646- db . execute ( `SELECT * FROM t1 ` ) ,
647- db . execute ( `SELECT * FROM t1 ` ) ,
648- db . execute ( `SELECT * FROM t1 ` )
649- ] ;
650-
651- await db . close ( ) ;
652-
653- const results = await Promise . allSettled ( tests ) ;
654- expect ( results . map ( ( r ) => r . status ) ) . deep . equal ( Array ( tests . length ) . fill ( 'rejected' ) ) ;
655- }
656- } ) ;
657-
658- it ( 'should compare results with old watch method' , async ( ) => {
622+ it ( 'should compare results with old watch method' , async ( ) => {
659623 const controller = new AbortController ( ) ;
660624
661625 const resultSets : QueryResult [ ] = [ ] ;
@@ -703,5 +667,43 @@ export function registerBaseTests() {
703667 // We should only have updated less than or equal 3 times
704668 expect ( resultSets . length ) . lessThanOrEqual ( 3 ) ;
705669 } ) ;
670+
671+ it ( 'Should handle multiple closes' , async ( ) => {
672+ // Bulk insert 10000 rows without using a transaction
673+ const bulkInsertCommands = [ ] ;
674+ const statement = `INSERT INTO t1(id, c) VALUES(uuid(), ?)` ;
675+
676+ for ( let i = 0 ; i < 10000 ; i ++ ) {
677+ bulkInsertCommands . push ( [ [ `value${ i + 1 } ` ] ] ) ;
678+ }
679+
680+ await db . executeBatch ( statement , bulkInsertCommands ) ;
681+ await db . close ( ) ;
682+
683+ for ( let i = 1 ; i < 10 ; i ++ ) {
684+ db = createDatabase ( ) ;
685+ await db . init ( ) ;
686+
687+ // ensure a regular query works
688+ const pExecute = await db . execute ( `SELECT * FROM t1 ` ) ;
689+ expect ( pExecute . rows ?. length ) . to . equal ( 10000 ) ;
690+
691+ // Queue a bunch of write locks, these will fail due to the db being closed
692+ // before they are accepted.
693+ const tests = [
694+ db . execute ( `SELECT * FROM t1 ` ) ,
695+ db . execute ( `SELECT * FROM t1 ` ) ,
696+ db . execute ( `SELECT * FROM t1 ` ) ,
697+ db . execute ( `SELECT * FROM t1 ` )
698+ ] ;
699+
700+ await db . close ( ) ;
701+
702+ const results = await Promise . allSettled ( tests ) ;
703+ expect ( results . map ( ( r ) => r . status ) ) . deep . equal ( Array ( tests . length ) . fill ( 'rejected' ) ) ;
704+ }
705+ } ) ;
706+
707+
706708 } ) ;
707709}
0 commit comments