11import { strict as assert } from 'node:assert'
2- import { describe , test , before , after } from 'node:test'
2+ import { describe , test } from 'node:test'
33import { GenericObjectPool } from '../../../index.wrapper.mjs'
44
55describe ( 'GenericObjectPool - Dynamic Sizing' , ( ) => {
@@ -133,7 +133,10 @@ describe('GenericObjectPool - Dynamic Sizing', () => {
133133 const resources = await Promise . all ( promises )
134134 assert . strictEqual ( resources . length , 3 )
135135
136- resources . forEach ( ( r ) => pool . release ( r ) )
136+ for ( const r of resources ) {
137+ pool . release ( r )
138+ }
139+
137140 pool . destroy ( )
138141 } )
139142
@@ -193,7 +196,7 @@ describe('GenericObjectPool - Dynamic Sizing', () => {
193196 const initialSize = pool . size
194197
195198 // Create concurrent demand to trigger scale-up
196- const resources = await Promise . all (
199+ await Promise . all (
197200 Array . from ( { length : 5 } , ( ) =>
198201 pool . acquireAsync ( 500 ) . then ( ( resource ) => {
199202 pool . release ( resource )
@@ -477,7 +480,10 @@ describe('GenericObjectPool - Dynamic Sizing', () => {
477480 pool . release ( r1 )
478481 pool . release ( r2 )
479482 const resources = await Promise . all ( promises )
480- resources . forEach ( ( r ) => pool . release ( r ) )
483+ for ( const r of resources ) {
484+ pool . release ( r )
485+ }
486+
481487 pool . destroy ( )
482488 } )
483489
@@ -514,16 +520,16 @@ describe('GenericObjectPool - Dynamic Sizing', () => {
514520 } )
515521
516522 const metrics = pool . getMetrics ( )
517- assert . ok ( metrics . hasOwnProperty ( 'currentSize' ) )
518- assert . ok ( metrics . hasOwnProperty ( 'minSize' ) )
519- assert . ok ( metrics . hasOwnProperty ( 'maxSize' ) )
520- assert . ok ( metrics . hasOwnProperty ( 'available' ) )
521- assert . ok ( metrics . hasOwnProperty ( 'inUse' ) )
522- assert . ok ( metrics . hasOwnProperty ( 'pending' ) )
523- assert . ok ( metrics . hasOwnProperty ( 'scaleUpEvents' ) )
524- assert . ok ( metrics . hasOwnProperty ( 'scaleDownEvents' ) )
525- assert . ok ( metrics . hasOwnProperty ( 'resourcesCreated' ) )
526- assert . ok ( metrics . hasOwnProperty ( 'resourcesDestroyed' ) )
523+ assert . ok ( 'currentSize' in metrics )
524+ assert . ok ( 'minSize' in metrics )
525+ assert . ok ( 'maxSize' in metrics )
526+ assert . ok ( 'available' in metrics )
527+ assert . ok ( 'inUse' in metrics )
528+ assert . ok ( 'pending' in metrics )
529+ assert . ok ( 'scaleUpEvents' in metrics )
530+ assert . ok ( 'scaleDownEvents' in metrics )
531+ assert . ok ( 'resourcesCreated' in metrics )
532+ assert . ok ( 'resourcesDestroyed' in metrics )
527533
528534 pool . destroy ( )
529535 } )
@@ -556,7 +562,9 @@ describe('GenericObjectPool - Dynamic Sizing', () => {
556562 assert . ok ( sizeAfterBurst1 > 2 , 'Should scale up during burst' )
557563
558564 // Release all
559- resources1 . forEach ( ( r ) => pool . release ( r ) )
565+ for ( const r of resources1 ) {
566+ pool . release ( r )
567+ }
560568
561569 // Idle period
562570 await new Promise ( ( resolve ) => setTimeout ( resolve , 300 ) )
@@ -573,13 +581,16 @@ describe('GenericObjectPool - Dynamic Sizing', () => {
573581
574582 assert . ok ( pool . size >= 8 , 'Should scale up again for second burst' )
575583
576- resources2 . forEach ( ( r ) => pool . release ( r ) )
584+ for ( const r of resources2 ) {
585+ pool . release ( r )
586+ }
587+
577588 pool . destroy ( )
578589 } )
579590
580591 test ( 'should handle resource destruction callbacks' , async ( ) => {
581592 let counter = 0
582- let destroyedIds = [ ]
593+ const destroyedIds = [ ]
583594
584595 const factory = ( ) => ( { id : counter ++ } )
585596 const destroyer = ( resource ) => {
@@ -620,7 +631,6 @@ describe('GenericObjectPool - Dynamic Sizing', () => {
620631 scaleUpIncrement : 2 ,
621632 } )
622633
623- const results = [ ]
624634 const promises = [ ]
625635
626636 for ( let i = 0 ; i < 5 ; i ++ ) {
0 commit comments