File tree Expand file tree Collapse file tree
lib/api/apiUtils/rateLimit
tests/unit/api/apiUtils/rateLimit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,14 +48,14 @@ function getCachedConfig(key) {
4848
4949function expireCachedConfigs ( now ) {
5050 const toRemove = [ ] ;
51- for ( const [ key , { expiry } ] of counters . entries ( ) ) {
51+ for ( const [ key , { expiry } ] of configCache . entries ( ) ) {
5252 if ( expiry <= now ) {
5353 toRemove . push ( key ) ;
5454 }
5555 }
5656
5757 for ( const key of toRemove ) {
58- counters . delete ( key ) ;
58+ configCache . delete ( key ) ;
5959 }
6060}
6161
Original file line number Diff line number Diff line change @@ -100,8 +100,11 @@ describe('test limit config cache storage', () => {
100100 config : 10 ,
101101 } ) ;
102102 expireCachedConfigs ( now ) ;
103- assert . strictEqual ( getCachedConfig ( 'past' ) , undefined ) ;
104- assert . strictEqual ( getCachedConfig ( 'present' ) , undefined ) ;
105- assert . strictEqual ( getCachedConfig ( 'future' ) , 10 ) ;
103+ assert . strictEqual ( configCache . get ( 'past' ) , undefined ) ;
104+ assert . strictEqual ( configCache . get ( 'present' ) , undefined ) ;
105+ assert . deepStrictEqual ( configCache . get ( 'future' ) , {
106+ expiry : now + 10000 ,
107+ config : 10 ,
108+ } ) ;
106109 } ) ;
107110} ) ;
You can’t perform that action at this time.
0 commit comments