From 0cfd9a7d720d186a0554aa1b495fadf8dad65a9c Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Wed, 8 May 2024 17:17:54 -0500 Subject: [PATCH] feat(shorebird_cli): introduce `createPatchMetadata` to `Patcher` (#2044) --- .../src/commands/patch_new/aar_patcher.dart | 22 +++++++ .../commands/patch_new/android_patcher.dart | 22 +++++++ .../commands/patch_new/patch_new_command.dart | 17 +---- .../lib/src/commands/patch_new/patcher.dart | 12 ++++ .../release_new/android_releaser.dart | 4 +- .../release_new/release_new_command.dart | 2 +- packages/shorebird_cli/pubspec.lock | 8 +-- .../commands/patch_new/aar_patcher_test.dart | 62 ++++++++++++++++++- .../patch_new/android_patcher_test.dart | 51 +++++++++++++++ .../patch_new/patch_new_command_test.dart | 24 ++++--- .../ios_framework_releaser_test.dart | 42 ++++++++----- packages/shorebird_cli/test/src/fakes.dart | 3 + 12 files changed, 219 insertions(+), 50 deletions(-) diff --git a/packages/shorebird_cli/lib/src/commands/patch_new/aar_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch_new/aar_patcher.dart index 1db018fe..c2cefb5a 100644 --- a/packages/shorebird_cli/lib/src/commands/patch_new/aar_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch_new/aar_patcher.dart @@ -10,6 +10,8 @@ import 'package:shorebird_cli/src/artifact_manager.dart'; import 'package:shorebird_cli/src/code_push_client_wrapper.dart'; import 'package:shorebird_cli/src/commands/patch_new/patch_new.dart'; import 'package:shorebird_cli/src/logger.dart'; +import 'package:shorebird_cli/src/patch_diff_checker.dart'; +import 'package:shorebird_cli/src/platform.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/shorebird_android_artifacts.dart'; @@ -17,6 +19,8 @@ import 'package:shorebird_cli/src/shorebird_env.dart'; import 'package:shorebird_cli/src/shorebird_flutter.dart'; import 'package:shorebird_cli/src/shorebird_validator.dart'; import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; +import 'package:shorebird_cli/src/version.dart'; +import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; /// {@template aar_patcher} /// Functions to patch an AAR release. @@ -159,4 +163,22 @@ class AarPatcher extends Patcher { 'Release version must be specified using --release-version.', ); } + + @override + Future createPatchMetadata(DiffStatus diffStatus) async { + return CreatePatchMetadata( + releasePlatform: releaseType.releasePlatform, + usedIgnoreAssetChangesFlag: allowAssetDiffs, + hasAssetChanges: diffStatus.hasAssetChanges, + usedIgnoreNativeChangesFlag: allowNativeDiffs, + hasNativeChanges: diffStatus.hasNativeChanges, + linkPercentage: null, + environment: BuildEnvironmentMetadata( + operatingSystem: platform.operatingSystem, + operatingSystemVersion: platform.operatingSystemVersion, + shorebirdVersion: packageVersion, + xcodeVersion: null, + ), + ); + } } diff --git a/packages/shorebird_cli/lib/src/commands/patch_new/android_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch_new/android_patcher.dart index e678f323..d3283bf6 100644 --- a/packages/shorebird_cli/lib/src/commands/patch_new/android_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch_new/android_patcher.dart @@ -9,12 +9,16 @@ import 'package:shorebird_cli/src/code_push_client_wrapper.dart'; import 'package:shorebird_cli/src/commands/patch_new/patcher.dart'; import 'package:shorebird_cli/src/doctor.dart'; import 'package:shorebird_cli/src/logger.dart'; +import 'package:shorebird_cli/src/patch_diff_checker.dart'; +import 'package:shorebird_cli/src/platform.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/shorebird_android_artifacts.dart'; import 'package:shorebird_cli/src/shorebird_flutter.dart'; import 'package:shorebird_cli/src/shorebird_validator.dart'; import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; +import 'package:shorebird_cli/src/version.dart'; +import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; /// {@template android_patcher} /// Functions to create an Android patch. @@ -166,4 +170,22 @@ Looked in: artifact.path, ); } + + @override + Future createPatchMetadata(DiffStatus diffStatus) async { + return CreatePatchMetadata( + releasePlatform: releaseType.releasePlatform, + usedIgnoreAssetChangesFlag: allowAssetDiffs, + hasAssetChanges: diffStatus.hasAssetChanges, + usedIgnoreNativeChangesFlag: allowNativeDiffs, + hasNativeChanges: diffStatus.hasNativeChanges, + linkPercentage: null, + environment: BuildEnvironmentMetadata( + operatingSystem: platform.operatingSystem, + operatingSystemVersion: platform.operatingSystemVersion, + shorebirdVersion: packageVersion, + xcodeVersion: null, + ), + ); + } } diff --git a/packages/shorebird_cli/lib/src/commands/patch_new/patch_new_command.dart b/packages/shorebird_cli/lib/src/commands/patch_new/patch_new_command.dart index c11612d8..f92cc60b 100644 --- a/packages/shorebird_cli/lib/src/commands/patch_new/patch_new_command.dart +++ b/packages/shorebird_cli/lib/src/commands/patch_new/patch_new_command.dart @@ -12,12 +12,10 @@ import 'package:shorebird_cli/src/extensions/arg_results.dart'; import 'package:shorebird_cli/src/formatters/formatters.dart'; import 'package:shorebird_cli/src/logger.dart'; import 'package:shorebird_cli/src/patch_diff_checker.dart'; -import 'package:shorebird_cli/src/platform.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/shorebird_env.dart'; import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; -import 'package:shorebird_cli/src/version.dart'; import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; typedef ResolvePatcher = Patcher Function(ReleaseType releaseType); @@ -220,20 +218,7 @@ NOTE: this is ${styleBold.wrap('not')} recommended. Asset changes cannot be incl await codePushClientWrapper.publishPatch( appId: appId, releaseId: release.id, - metadata: CreatePatchMetadata( - releasePlatform: patcher.releaseType.releasePlatform, - usedIgnoreAssetChangesFlag: allowAssetDiffs, - hasAssetChanges: diffStatus.hasAssetChanges, - usedIgnoreNativeChangesFlag: allowNativeDiffs, - hasNativeChanges: diffStatus.hasNativeChanges, - linkPercentage: null, - environment: BuildEnvironmentMetadata( - operatingSystem: platform.operatingSystem, - operatingSystemVersion: platform.operatingSystemVersion, - shorebirdVersion: packageVersion, - xcodeVersion: null, - ), - ), + metadata: await patcher.createPatchMetadata(diffStatus), platform: patcher.releaseType.releasePlatform, track: isStaging ? DeploymentTrack.staging : DeploymentTrack.production, diff --git a/packages/shorebird_cli/lib/src/commands/patch_new/patcher.dart b/packages/shorebird_cli/lib/src/commands/patch_new/patcher.dart index 31eb452f..fd3f51fc 100644 --- a/packages/shorebird_cli/lib/src/commands/patch_new/patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch_new/patcher.dart @@ -3,9 +3,11 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:shorebird_cli/src/archive_analysis/archive_differ.dart'; import 'package:shorebird_cli/src/code_push_client_wrapper.dart'; +import 'package:shorebird_cli/src/patch_diff_checker.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/shorebird_env.dart'; +import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; /// {@template patcher} /// Platform-specific functionality to create a patch. @@ -59,4 +61,14 @@ abstract class Patcher { required String appId, required int releaseId, }); + + /// Metadata to attach to the patch when creating it, used for debugging + /// and support. + Future createPatchMetadata(DiffStatus diffStatus); + + /// Whether to allow changes in assets (--allow-asset-diffs). + bool get allowAssetDiffs => argResults['allow-asset-diffs'] == true; + + /// Whether to allow changes in native code (--allow-native-diffs). + bool get allowNativeDiffs => argResults['allow-native-diffs'] == true; } diff --git a/packages/shorebird_cli/lib/src/commands/release_new/android_releaser.dart b/packages/shorebird_cli/lib/src/commands/release_new/android_releaser.dart index c4f05c0f..644dc394 100644 --- a/packages/shorebird_cli/lib/src/commands/release_new/android_releaser.dart +++ b/packages/shorebird_cli/lib/src/commands/release_new/android_releaser.dart @@ -1,12 +1,12 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:shorebird_cli/src/artifact_builder.dart'; import 'package:shorebird_cli/src/code_push_client_wrapper.dart'; -import 'package:shorebird_cli/src/release_type.dart'; -import 'package:shorebird_cli/src/commands/release_new/releaser.dart'; +import 'package:shorebird_cli/src/commands/release_new/release_new.dart'; import 'package:shorebird_cli/src/doctor.dart'; import 'package:shorebird_cli/src/logger.dart'; import 'package:shorebird_cli/src/platform.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; +import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/shorebird_android_artifacts.dart'; import 'package:shorebird_cli/src/shorebird_flutter.dart'; import 'package:shorebird_cli/src/shorebird_validator.dart'; diff --git a/packages/shorebird_cli/lib/src/commands/release_new/release_new_command.dart b/packages/shorebird_cli/lib/src/commands/release_new/release_new_command.dart index 6efb869d..5fc36a42 100644 --- a/packages/shorebird_cli/lib/src/commands/release_new/release_new_command.dart +++ b/packages/shorebird_cli/lib/src/commands/release_new/release_new_command.dart @@ -6,11 +6,11 @@ import 'package:scoped/scoped.dart'; import 'package:shorebird_cli/src/code_push_client_wrapper.dart'; import 'package:shorebird_cli/src/command.dart'; import 'package:shorebird_cli/src/commands/release_new/release_new.dart'; -import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/config/config.dart'; import 'package:shorebird_cli/src/extensions/arg_results.dart'; import 'package:shorebird_cli/src/logger.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; +import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/shorebird_env.dart'; import 'package:shorebird_cli/src/shorebird_flutter.dart'; import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; diff --git a/packages/shorebird_cli/pubspec.lock b/packages/shorebird_cli/pubspec.lock index 09d2d087..412b1bff 100644 --- a/packages/shorebird_cli/pubspec.lock +++ b/packages/shorebird_cli/pubspec.lock @@ -428,10 +428,10 @@ packages: dependency: "direct main" description: name: meta - sha256: "25dfcaf170a0190f47ca6355bdd4552cb8924b430512ff0cafb8db9bd41fe33b" + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.14.0" + version: "1.15.0" mime: dependency: transitive description: @@ -492,10 +492,10 @@ packages: dependency: transitive description: name: pointycastle - sha256: "79fbafed02cfdbe85ef3fd06c7f4bc2cbcba0177e61b765264853d4253b21744" + sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe" url: "https://pub.dev" source: hosted - version: "3.9.0" + version: "3.9.1" pool: dependency: transitive description: diff --git a/packages/shorebird_cli/test/src/commands/patch_new/aar_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch_new/aar_patcher_test.dart index a516b39b..26f5de74 100644 --- a/packages/shorebird_cli/test/src/commands/patch_new/aar_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch_new/aar_patcher_test.dart @@ -2,6 +2,7 @@ import 'package:args/args.dart'; import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:path/path.dart' as p; +import 'package:platform/platform.dart'; import 'package:scoped/scoped.dart'; import 'package:shorebird_cli/src/archive_analysis/archive_analysis.dart'; import 'package:shorebird_cli/src/artifact_builder.dart'; @@ -10,6 +11,8 @@ import 'package:shorebird_cli/src/code_push_client_wrapper.dart'; import 'package:shorebird_cli/src/commands/patch_new/patch_new.dart'; import 'package:shorebird_cli/src/engine_config.dart'; import 'package:shorebird_cli/src/logger.dart'; +import 'package:shorebird_cli/src/patch_diff_checker.dart'; +import 'package:shorebird_cli/src/platform.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; import 'package:shorebird_cli/src/release_type.dart'; import 'package:shorebird_cli/src/shorebird_android_artifacts.dart'; @@ -17,6 +20,7 @@ import 'package:shorebird_cli/src/shorebird_env.dart'; import 'package:shorebird_cli/src/shorebird_flutter.dart'; import 'package:shorebird_cli/src/shorebird_validator.dart'; import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; +import 'package:shorebird_cli/src/version.dart'; import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; import 'package:test/test.dart'; @@ -34,6 +38,7 @@ void main() { late CodePushClientWrapper codePushClientWrapper; late Directory projectRoot; late Logger logger; + late Platform platform; late Progress progress; late ShorebirdEnv shorebirdEnv; late ShorebirdFlutter shorebirdFlutter; @@ -51,11 +56,13 @@ void main() { codePushClientWrapperRef.overrideWith(() => codePushClientWrapper), engineConfigRef.overrideWith(() => const EngineConfig.empty()), loggerRef.overrideWith(() => logger), + platformRef.overrideWith(() => platform), shorebirdEnvRef.overrideWith(() => shorebirdEnv), shorebirdFlutterRef.overrideWith(() => shorebirdFlutter), shorebirdValidatorRef.overrideWith(() => shorebirdValidator), - shorebirdAndroidArtifactsRef - .overrideWith(() => shorebirdAndroidArtifacts), + shorebirdAndroidArtifactsRef.overrideWith( + () => shorebirdAndroidArtifacts, + ), }, ); } @@ -86,7 +93,7 @@ void main() { artifactBuilder = MockArtifactBuilder(); artifactManager = MockArtifactManager(); codePushClientWrapper = MockCodePushClientWrapper(); - // platform = MockPlatform(); + platform = MockPlatform(); progress = MockProgress(); projectRoot = Directory.systemTemp.createTempSync(); logger = MockLogger(); @@ -416,5 +423,54 @@ void main() { ); }); }); + + group('createPatchMetadata', () { + const allowAssetDiffs = false; + const allowNativeDiffs = true; + const operatingSystem = 'Mac OS X'; + const operatingSystemVersion = '10.15.7'; + + setUp(() { + when(() => argResults['allow-asset-diffs']).thenReturn(allowAssetDiffs); + when( + () => argResults['allow-native-diffs'], + ).thenReturn(allowNativeDiffs); + when(() => platform.operatingSystem).thenReturn(operatingSystem); + when( + () => platform.operatingSystemVersion, + ).thenReturn(operatingSystemVersion); + }); + + test('returns correct metadata', () async { + final diffStatus = DiffStatus( + hasAssetChanges: false, + hasNativeChanges: false, + ); + + final metadata = await runWithOverrides( + () => patcher.createPatchMetadata(diffStatus), + ); + + expect( + metadata, + equals( + CreatePatchMetadata( + releasePlatform: ReleasePlatform.android, + usedIgnoreAssetChangesFlag: allowAssetDiffs, + hasAssetChanges: diffStatus.hasAssetChanges, + usedIgnoreNativeChangesFlag: allowNativeDiffs, + hasNativeChanges: diffStatus.hasNativeChanges, + linkPercentage: null, + environment: const BuildEnvironmentMetadata( + operatingSystem: operatingSystem, + operatingSystemVersion: operatingSystemVersion, + shorebirdVersion: packageVersion, + xcodeVersion: null, + ), + ), + ), + ); + }); + }); }); } diff --git a/packages/shorebird_cli/test/src/commands/patch_new/android_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch_new/android_patcher_test.dart index 30ab9fdf..51b51fd4 100644 --- a/packages/shorebird_cli/test/src/commands/patch_new/android_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch_new/android_patcher_test.dart @@ -12,6 +12,7 @@ import 'package:shorebird_cli/src/commands/patch_new/patch_new.dart'; import 'package:shorebird_cli/src/doctor.dart'; import 'package:shorebird_cli/src/engine_config.dart'; import 'package:shorebird_cli/src/logger.dart'; +import 'package:shorebird_cli/src/patch_diff_checker.dart'; import 'package:shorebird_cli/src/platform.dart'; import 'package:shorebird_cli/src/platform/platform.dart'; import 'package:shorebird_cli/src/shorebird_android_artifacts.dart'; @@ -21,6 +22,7 @@ import 'package:shorebird_cli/src/shorebird_process.dart'; import 'package:shorebird_cli/src/shorebird_validator.dart'; import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; import 'package:shorebird_cli/src/validators/validators.dart'; +import 'package:shorebird_cli/src/version.dart'; import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; import 'package:test/test.dart'; @@ -447,5 +449,54 @@ Looked in: ).thenReturn(aabFile); }); }); + + group('createPatchMetadata', () { + const allowAssetDiffs = false; + const allowNativeDiffs = true; + const operatingSystem = 'Mac OS X'; + const operatingSystemVersion = '10.15.7'; + + setUp(() { + when(() => argResults['allow-asset-diffs']).thenReturn(allowAssetDiffs); + when( + () => argResults['allow-native-diffs'], + ).thenReturn(allowNativeDiffs); + when(() => platform.operatingSystem).thenReturn(operatingSystem); + when( + () => platform.operatingSystemVersion, + ).thenReturn(operatingSystemVersion); + }); + + test('returns correct metadata', () async { + final diffStatus = DiffStatus( + hasAssetChanges: false, + hasNativeChanges: false, + ); + + final metadata = await runWithOverrides( + () => patcher.createPatchMetadata(diffStatus), + ); + + expect( + metadata, + equals( + CreatePatchMetadata( + releasePlatform: ReleasePlatform.android, + usedIgnoreAssetChangesFlag: allowAssetDiffs, + hasAssetChanges: diffStatus.hasAssetChanges, + usedIgnoreNativeChangesFlag: allowNativeDiffs, + hasNativeChanges: diffStatus.hasNativeChanges, + linkPercentage: null, + environment: const BuildEnvironmentMetadata( + operatingSystem: operatingSystem, + operatingSystemVersion: operatingSystemVersion, + shorebirdVersion: packageVersion, + xcodeVersion: null, + ), + ), + ), + ); + }); + }); }); } diff --git a/packages/shorebird_cli/test/src/commands/patch_new/patch_new_command_test.dart b/packages/shorebird_cli/test/src/commands/patch_new/patch_new_command_test.dart index 1b1ef1b7..dfad943d 100644 --- a/packages/shorebird_cli/test/src/commands/patch_new/patch_new_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch_new/patch_new_command_test.dart @@ -21,6 +21,7 @@ import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; import 'package:test/test.dart'; +import '../../fakes.dart'; import '../../matchers.dart'; import '../../mocks.dart'; @@ -33,6 +34,7 @@ void main() { const releasePlatform = ReleasePlatform.android; const releaseVersion = '1.2.3+1'; const shorebirdYaml = ShorebirdYaml(appId: appId); + final patchMetadata = CreatePatchMetadata.forTest(); final appMetadata = AppMetadata( appId: appId, @@ -101,6 +103,7 @@ void main() { setUpAll(() { registerFallbackValue(CreatePatchMetadata.forTest()); registerFallbackValue(DeploymentTrack.production); + registerFallbackValue(FakeDiffStatus()); registerFallbackValue(Directory('')); registerFallbackValue(File('')); registerFallbackValue(FileSetDiff.empty()); @@ -129,8 +132,9 @@ void main() { when(() => argResults['release-version']).thenReturn(releaseVersion); when(() => argResults.wasParsed(any())).thenReturn(true); - when(() => artifactManager.downloadFile(any())) - .thenAnswer((_) async => File('')); + when( + () => artifactManager.downloadFile(any()), + ).thenAnswer((_) async => File('')); when(() => codePushClientWrapper.getApp(appId: any(named: 'appId'))) .thenAnswer((_) async => appMetadata); @@ -195,10 +199,12 @@ void main() { when(() => patcher.archiveDiffer).thenReturn(archiveDiffer); when(() => patcher.assertArgsAreValid()).thenAnswer((_) async {}); when(() => patcher.assertPreconditions()).thenAnswer((_) async {}); - when(() => patcher.extractReleaseVersionFromArtifact(any())) - .thenAnswer((_) async => releaseVersion); - when(() => patcher.buildPatchArtifact()) - .thenAnswer((_) async => File('')); + when( + () => patcher.extractReleaseVersionFromArtifact(any()), + ).thenAnswer((_) async => releaseVersion); + when( + () => patcher.buildPatchArtifact(), + ).thenAnswer((_) async => File('')); when(() => patcher.releaseType).thenReturn(ReleaseType.android); when(() => patcher.primaryReleaseArtifactArch).thenReturn('aab'); when( @@ -216,6 +222,9 @@ void main() { ), }, ); + when( + () => patcher.createPatchMetadata(any()), + ).thenAnswer((_) async => patchMetadata); when(() => shorebirdEnv.getShorebirdYaml()).thenReturn(shorebirdYaml); when(() => shorebirdEnv.flutterRevision).thenReturn(flutterRevision); @@ -311,10 +320,11 @@ void main() { releaseId: release.id, ), () => logger.confirm('Would you like to continue?'), + () => patcher.createPatchMetadata(any()), () => codePushClientWrapper.publishPatch( appId: appId, releaseId: release.id, - metadata: any(named: 'metadata'), + metadata: patchMetadata, platform: releasePlatform, patchArtifactBundles: any(named: 'patchArtifactBundles'), track: DeploymentTrack.production, diff --git a/packages/shorebird_cli/test/src/commands/release_new/ios_framework_releaser_test.dart b/packages/shorebird_cli/test/src/commands/release_new/ios_framework_releaser_test.dart index d79d6bf3..8f079489 100644 --- a/packages/shorebird_cli/test/src/commands/release_new/ios_framework_releaser_test.dart +++ b/packages/shorebird_cli/test/src/commands/release_new/ios_framework_releaser_test.dart @@ -137,8 +137,9 @@ void main() { group('when arguments are valid', () { setUp(() { - when(() => argResults.wasParsed('release-version')) - .thenReturn(true); + when( + () => argResults.wasParsed('release-version'), + ).thenReturn(true); }); test('returns normally', () { @@ -152,8 +153,9 @@ void main() { group('assertPreconditions', () { setUp(() { - when(() => doctor.iosCommandValidators) - .thenReturn([flutterValidator]); + when( + () => doctor.iosCommandValidators, + ).thenReturn([flutterValidator]); when(flutterValidator.validate).thenAnswer((_) async => []); }); @@ -161,13 +163,16 @@ void main() { setUp(() { when( () => shorebirdValidator.validatePreconditions( - checkUserIsAuthenticated: - any(named: 'checkUserIsAuthenticated'), - checkShorebirdInitialized: - any(named: 'checkShorebirdInitialized'), + checkUserIsAuthenticated: any( + named: 'checkUserIsAuthenticated', + ), + checkShorebirdInitialized: any( + named: 'checkShorebirdInitialized', + ), validators: any(named: 'validators'), - supportedOperatingSystems: - any(named: 'supportedOperatingSystems'), + supportedOperatingSystems: any( + named: 'supportedOperatingSystems', + ), ), ).thenAnswer((_) async {}); }); @@ -186,13 +191,16 @@ void main() { setUp(() { when( () => shorebirdValidator.validatePreconditions( - checkUserIsAuthenticated: - any(named: 'checkUserIsAuthenticated'), - checkShorebirdInitialized: - any(named: 'checkShorebirdInitialized'), + checkUserIsAuthenticated: any( + named: 'checkUserIsAuthenticated', + ), + checkShorebirdInitialized: any( + named: 'checkShorebirdInitialized', + ), validators: any(named: 'validators'), - supportedOperatingSystems: - any(named: 'supportedOperatingSystems'), + supportedOperatingSystems: any( + named: 'supportedOperatingSystems', + ), ), ).thenThrow(exception); }); @@ -260,7 +268,7 @@ void main() { }); group('when build succeeds', () { - test('produces aar in release directory', () async { + test('produces xcframework in release directory', () async { final xcframework = await runWithOverrides( iosFrameworkReleaser.buildReleaseArtifacts, ); diff --git a/packages/shorebird_cli/test/src/fakes.dart b/packages/shorebird_cli/test/src/fakes.dart index df4f970c..eb9d2b96 100644 --- a/packages/shorebird_cli/test/src/fakes.dart +++ b/packages/shorebird_cli/test/src/fakes.dart @@ -1,10 +1,13 @@ import 'package:http/http.dart' as http; import 'package:mocktail/mocktail.dart'; +import 'package:shorebird_cli/src/patch_diff_checker.dart'; import 'package:shorebird_cli/src/shorebird_process.dart'; import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; class FakeBaseRequest extends Fake implements http.BaseRequest {} +class FakeDiffStatus extends Fake implements DiffStatus {} + class FakeRelease extends Fake implements Release {} class FakeShorebirdProcess extends Fake implements ShorebirdProcess {}