@@ -225,7 +225,7 @@ test.serial(
225225 . returns ( "true" ) ;
226226 sinon . stub ( gitUtils , "isAnalyzingDefaultBranch" ) . resolves ( true ) ;
227227
228- await mockHttpRequests ( 422 ) ;
228+ const databaseUploadSpy = await mockHttpRequests ( 422 ) ;
229229
230230 const loggedMessages = [ ] as LoggedMessage [ ] ;
231231 await cleanupAndUploadDatabases (
@@ -245,6 +245,9 @@ test.serial(
245245 "Failed to upload database for javascript: some error message" ,
246246 ) !== undefined ,
247247 ) ;
248+
249+ // Non-retryable errors should not be retried.
250+ t . is ( databaseUploadSpy . callCount , 1 ) ;
248251 } ) ;
249252 } ,
250253) ;
@@ -260,11 +263,11 @@ test.serial(
260263 . returns ( "true" ) ;
261264 sinon . stub ( gitUtils , "isAnalyzingDefaultBranch" ) . resolves ( true ) ;
262265
263- await mockHttpRequests ( 500 ) ;
266+ const databaseUploadSpy = await mockHttpRequests ( 500 ) ;
264267
265268 // Stub setTimeout to fire immediately to avoid real delays from retry backoff.
266269 const originalSetTimeout = global . setTimeout ;
267- sinon
270+ const setTimeoutStub = sinon
268271 . stub ( global , "setTimeout" )
269272 . callsFake ( ( fn : ( ) => void ) => originalSetTimeout ( fn , 0 ) ) ;
270273
@@ -286,6 +289,15 @@ test.serial(
286289 "Failed to upload database for javascript: some error message" ,
287290 ) !== undefined ,
288291 ) ;
292+
293+ // Retryable errors should be retried the expected number of times.
294+ t . is ( databaseUploadSpy . callCount , 4 ) ;
295+
296+ // setTimeout should have been called with the expected backoff delays.
297+ const setTimeoutDelays = setTimeoutStub . args . map (
298+ ( args ) => args [ 1 ] as number ,
299+ ) ;
300+ t . deepEqual ( setTimeoutDelays , [ 15_000 , 30_000 , 60_000 ] ) ;
289301 } ) ;
290302 } ,
291303) ;
0 commit comments