@@ -171,48 +171,6 @@ describe('EventBuffer with real Redis', () => {
171171 insertSpy . mockRestore ( ) ;
172172 } ) ;
173173
174- it ( 'respects EVENT_BUFFER_BATCH_SIZE' , async ( ) => {
175- const prev = process . env . EVENT_BUFFER_BATCH_SIZE ;
176- process . env . EVENT_BUFFER_BATCH_SIZE = '2' ;
177- const eb = new EventBuffer ( ) ;
178-
179- const events = Array . from ( { length : 5 } , ( _ , i ) => ( {
180- project_id : 'p1' ,
181- name : `event${ i } ` ,
182- created_at : new Date ( Date . now ( ) + i * 100 ) . toISOString ( ) ,
183- } ) ) ;
184-
185- for ( const event of events ) {
186- await eb . add ( event as any ) ;
187- }
188-
189- const insertSpy = vi
190- . spyOn ( ch , 'insert' )
191- . mockResolvedValue ( undefined as any ) ;
192-
193- await eb . processBuffer ( ) ;
194-
195- // Only first 2 events should be processed (batchSize = 2)
196- expect ( insertSpy ) . toHaveBeenCalledOnce ( ) ;
197- const insertCall = insertSpy . mock . calls [ 0 ] ! [ 0 ] as any ;
198- expect ( insertCall . format ) . toBe ( 'JSONEachRow' ) ;
199- expect ( insertCall . table ) . toBe ( 'events' ) ;
200- expect ( insertCall . values ) . toHaveLength ( 2 ) ;
201- expect ( insertCall . values [ 0 ] ) . toMatchObject ( { name : 'event0' } ) ;
202- expect ( insertCall . values [ 1 ] ) . toMatchObject ( { name : 'event1' } ) ;
203-
204- // 3 events should remain in buffer
205- const bufferKey = 'event-buffer' ;
206- const remaining = await redis . lrange ( bufferKey , 0 , - 1 ) ;
207- expect ( remaining . length ) . toBe ( 3 ) ;
208-
209- // Restore env
210- if ( prev === undefined ) delete process . env . EVENT_BUFFER_BATCH_SIZE ;
211- else process . env . EVENT_BUFFER_BATCH_SIZE = prev ;
212-
213- insertSpy . mockRestore ( ) ;
214- } ) ;
215-
216174 it ( 'inserts in chunks according to EVENT_BUFFER_CHUNK_SIZE' , async ( ) => {
217175 const prev = process . env . EVENT_BUFFER_CHUNK_SIZE ;
218176 const prevBatch = process . env . EVENT_BUFFER_BATCH_SIZE ;
0 commit comments