diff --git a/packages/shorebird_cli/lib/src/code_push_client_wrapper.dart b/packages/shorebird_cli/lib/src/code_push_client_wrapper.dart index 206673c0..9b7ee05f 100644 --- a/packages/shorebird_cli/lib/src/code_push_client_wrapper.dart +++ b/packages/shorebird_cli/lib/src/code_push_client_wrapper.dart @@ -810,7 +810,9 @@ aar artifact already exists, continuing...''', } /// Returns a GCP upload link for measuring upload speed. - Future getGCPSpeedTestUrl() => codePushClient.getGCPSpeedTestUrl(); + Future getGCPUploadSpeedTestUrl() { + return codePushClient.getGCPUploadSpeedTestUrl(); + } /// Prints an appropriate error message for the given error and exits with /// code 70. If [progress] is provided, it will be failed with the given diff --git a/packages/shorebird_cli/lib/src/commands/doctor_command.dart b/packages/shorebird_cli/lib/src/commands/doctor_command.dart index 6cbfd732..9c728c75 100644 --- a/packages/shorebird_cli/lib/src/commands/doctor_command.dart +++ b/packages/shorebird_cli/lib/src/commands/doctor_command.dart @@ -104,12 +104,14 @@ Android Toolchain final progress = logger.progress('Performing GCP speed test'); try { - final speed = await networkChecker.performGCPSpeedTest(); - progress.complete('GCP Upload Speed: ${speed.toStringAsFixed(2)} MB/s'); + final uploadSpeed = await networkChecker.performGCPUploadSpeedTest(); + progress.complete( + 'GCP Upload Speed: ${uploadSpeed.toStringAsFixed(2)} MB/s', + ); } on NetworkCheckerException catch (error) { - progress.fail('GCP speed test failed: ${error.message}'); + progress.fail('GCP upload speed test failed: ${error.message}'); } catch (error) { - progress.fail('GCP speed test failed: $error'); + progress.fail('GCP upload speed test failed: $error'); } } diff --git a/packages/shorebird_cli/lib/src/network_checker.dart b/packages/shorebird_cli/lib/src/network_checker.dart index cdc5f270..a1bfbdad 100644 --- a/packages/shorebird_cli/lib/src/network_checker.dart +++ b/packages/shorebird_cli/lib/src/network_checker.dart @@ -57,7 +57,7 @@ class NetworkChecker { /// Uploads a file to GCP to measure upload speed. Returns the upload rate /// in MB/s. - Future performGCPSpeedTest({ + Future performGCPUploadSpeedTest({ // If they can't upload the file in two minutes, we can just say it's slow. Duration uploadTimeout = const Duration(minutes: 2), }) async { @@ -69,7 +69,7 @@ class NetworkChecker { final testFile = File(p.join(tempDir.path, 'speed_test_file')) ..writeAsBytesSync(ByteData(fileSize).buffer.asUint8List()); try { - final uri = await codePushClientWrapper.getGCPSpeedTestUrl(); + final uri = await codePushClientWrapper.getGCPUploadSpeedTestUrl(); final start = clock.now(); final file = await http.MultipartFile.fromPath('file', testFile.path); final uploadRequest = http.MultipartRequest('POST', uri)..files.add(file); diff --git a/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart b/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart index daa19c88..7066d962 100644 --- a/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart +++ b/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart @@ -2361,11 +2361,11 @@ You can manage this release in the ${link(uri: uri, message: 'Shorebird Console' }); }); - group('getGCPSpeedTestUrl', () { + group('getGCPUploadSpeedTestUrl', () { final gcpSpeedTestUrl = Uri.parse('https://speedtest.gcp.com'); setUp(() { - when(() => codePushClient.getGCPSpeedTestUrl()).thenAnswer( + when(() => codePushClient.getGCPUploadSpeedTestUrl()).thenAnswer( (_) async => gcpSpeedTestUrl, ); }); @@ -2373,12 +2373,12 @@ You can manage this release in the ${link(uri: uri, message: 'Shorebird Console' test('calls codePushClient method', () async { await expectLater( runWithOverrides( - () => codePushClientWrapper.getGCPSpeedTestUrl(), + () => codePushClientWrapper.getGCPUploadSpeedTestUrl(), ), completion(gcpSpeedTestUrl), ); - verify(() => codePushClient.getGCPSpeedTestUrl()).called(1); + verify(() => codePushClient.getGCPUploadSpeedTestUrl()).called(1); }); }); }); diff --git a/packages/shorebird_cli/test/src/commands/doctor_command_test.dart b/packages/shorebird_cli/test/src/commands/doctor_command_test.dart index 0e6dd6cd..b5724312 100644 --- a/packages/shorebird_cli/test/src/commands/doctor_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/doctor_command_test.dart @@ -83,7 +83,7 @@ void main() { () => networkChecker.checkReachability(), ).thenAnswer((_) async => {}); when( - () => networkChecker.performGCPSpeedTest(), + () => networkChecker.performGCPUploadSpeedTest(), ).thenAnswer((_) async => 1.0); when( () => shorebirdEnv.shorebirdEngineRevision, @@ -134,14 +134,14 @@ Engine • revision $shorebirdEngineRevision '''), ).called(1); verify(() => networkChecker.checkReachability()).called(1); - verifyNever(() => networkChecker.performGCPSpeedTest()); + verifyNever(() => networkChecker.performGCPUploadSpeedTest()); }); group('--verbose', () { setUp(() { when(() => argResults['verbose']).thenReturn(true); when( - () => networkChecker.performGCPSpeedTest(), + () => networkChecker.performGCPUploadSpeedTest(), ).thenAnswer((_) async => 1.23456789); }); @@ -219,7 +219,7 @@ Android Toolchain ); verify(() => networkChecker.checkReachability()).called(1); - verify(() => networkChecker.performGCPSpeedTest()).called(1); + verify(() => networkChecker.performGCPUploadSpeedTest()).called(1); verify( () => progress.complete('GCP Upload Speed: 1.23 MB/s'), ).called(1); @@ -289,7 +289,7 @@ Android Toolchain group('with NetworkCheckerException', () { setUp(() { when( - () => networkChecker.performGCPSpeedTest(), + () => networkChecker.performGCPUploadSpeedTest(), ).thenThrow(const NetworkCheckerException('oops')); }); @@ -300,7 +300,7 @@ Android Toolchain ); verify( - () => progress.fail('GCP speed test failed: oops'), + () => progress.fail('GCP upload speed test failed: oops'), ).called(1); }); }); @@ -308,7 +308,7 @@ Android Toolchain group('with generic Exception', () { setUp(() { when( - () => networkChecker.performGCPSpeedTest(), + () => networkChecker.performGCPUploadSpeedTest(), ).thenThrow(Exception('oops')); }); @@ -319,7 +319,9 @@ Android Toolchain ); verify( - () => progress.fail('GCP speed test failed: Exception: oops'), + () => progress.fail( + 'GCP upload speed test failed: Exception: oops', + ), ).called(1); }); }); diff --git a/packages/shorebird_cli/test/src/network_checker_test.dart b/packages/shorebird_cli/test/src/network_checker_test.dart index e4a99855..4c14b0d9 100644 --- a/packages/shorebird_cli/test/src/network_checker_test.dart +++ b/packages/shorebird_cli/test/src/network_checker_test.dart @@ -82,11 +82,11 @@ void main() { }); }); - group('performGCPSpeedTest', () { + group('performGCPUploadSpeedTest', () { final gcpUri = Uri.parse('http://localhost'); setUp(() { - when(() => codePushClientWrapper.getGCPSpeedTestUrl()).thenAnswer( + when(() => codePushClientWrapper.getGCPUploadSpeedTestUrl()).thenAnswer( (_) async => gcpUri, ); }); @@ -103,7 +103,7 @@ void main() { test('throws a NetworkCheckerException', () async { await expectLater( - runWithOverrides(networkChecker.performGCPSpeedTest), + runWithOverrides(networkChecker.performGCPUploadSpeedTest), throwsA( isA().having( (e) => e.message, @@ -135,7 +135,7 @@ void main() { test('throws a NetworkCheckerException', () async { await expectLater( () => runWithOverrides( - () => networkChecker.performGCPSpeedTest( + () => networkChecker.performGCPUploadSpeedTest( uploadTimeout: uploadTimeout, ), ), @@ -177,8 +177,9 @@ void main() { } }); await withClock(clock, () async { - final speed = - await runWithOverrides(networkChecker.performGCPSpeedTest); + final speed = await runWithOverrides( + networkChecker.performGCPUploadSpeedTest, + ); // Our 5MB file took 1 second to upload, so our speed is 5 MB/s. expect(speed, equals(5.0)); diff --git a/packages/shorebird_code_push_client/lib/src/code_push_client.dart b/packages/shorebird_code_push_client/lib/src/code_push_client.dart index 95b39533..272f2419 100644 --- a/packages/shorebird_code_push_client/lib/src/code_push_client.dart +++ b/packages/shorebird_code_push_client/lib/src/code_push_client.dart @@ -502,7 +502,7 @@ class CodePushClient { } /// Returns a GCP upload link for measuring upload speed. - Future getGCPSpeedTestUrl() async { + Future getGCPUploadSpeedTestUrl() async { final response = await _httpClient.get( Uri.parse('$_v1/diagnostics/gcp_upload'), ); diff --git a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart index c95a92f7..a385c8f8 100644 --- a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart +++ b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart @@ -1978,7 +1978,7 @@ void main() { }); }); - group('getGCPSpeedTestUrl', () { + group('getGCPUploadSpeedTestUrl', () { group('when request fails', () { setUp(() { when(() => httpClient.send(any())).thenAnswer( @@ -1991,7 +1991,7 @@ void main() { test('throws exception', () async { expect( - () async => codePushClient.getGCPSpeedTestUrl(), + () async => codePushClient.getGCPUploadSpeedTestUrl(), throwsA( isA().having( (e) => e.message, @@ -2016,7 +2016,7 @@ void main() { }); test('returns upload_url as parsed Uri', () async { - final url = await codePushClient.getGCPSpeedTestUrl(); + final url = await codePushClient.getGCPUploadSpeedTestUrl(); expect(url, equals(Uri.parse('https://example.com'))); }); });