From e795400d2da4dd54acfb1feeffba2f703b201e6a Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Mon, 2 Feb 2026 08:22:35 -0800 Subject: [PATCH] fix: fix flaky network checker timeout tests (#3494) --- .../test/src/network_checker_test.dart | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/shorebird_cli/test/src/network_checker_test.dart b/packages/shorebird_cli/test/src/network_checker_test.dart index 3ed5f01e..fc433432 100644 --- a/packages/shorebird_cli/test/src/network_checker_test.dart +++ b/packages/shorebird_cli/test/src/network_checker_test.dart @@ -121,19 +121,15 @@ void main() { group('when download times out', () { const downloadTimeout = Duration(milliseconds: 1); - // Make this a healthy multiple of the upload timeout to avoid flakiness - // on slow (read: Windows) CI machines. - final responseTime = downloadTimeout * 100; setUp(() { + // Use a Completer that never completes so the timeout always fires, + // regardless of how slow the CI machine is. when( () => artifactManager.downloadFile( any(), outputPath: any(named: 'outputPath'), ), - ).thenAnswer((_) async { - await Future.delayed(responseTime); - return File(''); - }); + ).thenAnswer((_) => Completer().future); }); test('throws a NetworkCheckerException', () async { @@ -256,17 +252,12 @@ void main() { group('when upload times out', () { const uploadTimeout = Duration(milliseconds: 1); - // Make this a healthy multiple of the upload timeout to avoid flakiness - // on slow (read: Windows) CI machines. - final responseTime = uploadTimeout * 5; setUp(() { - when(() => httpClient.send(any())).thenAnswer((_) async { - await Future.delayed(responseTime); - return http.StreamedResponse( - const Stream.empty(), - HttpStatus.noContent, - ); - }); + // Use a Completer that never completes so the timeout always fires, + // regardless of how slow the CI machine is. + when( + () => httpClient.send(any()), + ).thenAnswer((_) => Completer().future); }); test('throws a NetworkCheckerException', () async {