diff --git a/.github/actions/flutter_package/action.yaml b/.github/actions/flutter_package/action.yaml index 027c28f3..2ba04a62 100644 --- a/.github/actions/flutter_package/action.yaml +++ b/.github/actions/flutter_package/action.yaml @@ -29,10 +29,10 @@ inputs: required: false default: "lib" description: Directories to report on when collecting coverage - platform: + example_platform: required: false - default: "vm" - description: Platform to use when running tests + default: "web" + description: Platform to use when building example runs: using: "composite" @@ -54,6 +54,11 @@ runs: shell: ${{ inputs.shell }} run: dart analyze --fatal-warnings ${{inputs.analyze_directories}} + - name: Build Example + working-directory: ${{ inputs.working_directory }}/example + shell: ${{ inputs.shell }} + run: flutter build ${{ inputs.example_platform }} + - name: Test working-directory: ${{ inputs.working_directory }} shell: ${{ inputs.shell }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 3e5c5d04..77f44762 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -12,6 +12,12 @@ jobs: name: ✅ Semantic Pull Request uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1 + cspell: + name: 🔤 Check Spelling + uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/spell_check.yml@v1 + with: + config: cspell.config.yaml + changes: runs-on: ubuntu-latest diff --git a/cspell.config.yaml b/cspell.config.yaml new file mode 100644 index 00000000..00b666ed --- /dev/null +++ b/cspell.config.yaml @@ -0,0 +1,70 @@ +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: '0.2' +ignorePaths: + - target + - build + - '**/*.g.dart' + # Flutter platform directories with per-platform build files + - windows + - macos + - linux + - ios + - android +words: + - aarch + - androideabi + - apks + - armeabi + - armv7 + - autogen + - bidiff + - bipatch + - bootable + - buildroot + - bundletool + - carryforward + - cbindgen + - cdylib + - classpath + - comde + - compatch + - Condvar + - datadir + - declspec + - Decompressor + - dllexport + - dlopen + - endtemplate + - eseidel + - ffigen + - gclient + - hdpi + - ifdef + - libapp + - libc + - libflutter + - libupdater + - logcat + - mockall + - mocktail + - oslog + - pubspec + - repr + - reqwest + - rollouts + - rustls + - rustup + - serde + - shorebirdtech + - sigstore + - staticlib + - subosito + - unbootable + - Verdana + - vmcode + - withf + - xlink + - zstandard + - zstd + - xcodeproj + - pbxproj \ No newline at end of file diff --git a/library/README.md b/library/README.md index 27132bb3..3493445d 100644 --- a/library/README.md +++ b/library/README.md @@ -182,7 +182,7 @@ This state machine tracks the process of checking for new patches. It is managed by the code in `updater.rs` and does not have any on-disk state. It has the following states: -1. Ready - Ready to check for udpates. +1. Ready - Ready to check for updates. 2. Send queued events (e.g., report that a patch succeeded or failed to boot) a. Move to checking once events, if any, have been reported. 3. Checking for new patches - A PatchCheckRequest is issued but not completed. diff --git a/library/src/android.rs b/library/src/android.rs index 54a82580..adc8c169 100644 --- a/library/src/android.rs +++ b/library/src/android.rs @@ -1,3 +1,4 @@ +// cspell:ignore rpkDZSLBRv2jWcc1gQpwdg use anyhow::Context; use std::fs; use std::io::{Cursor, Read}; diff --git a/library/src/c_api/c_file.rs b/library/src/c_api/c_file.rs index c66b4a33..8446343b 100644 --- a/library/src/c_api/c_file.rs +++ b/library/src/c_api/c_file.rs @@ -10,11 +10,11 @@ struct CFile { } #[derive(Clone, Debug)] -pub struct CFileProvder { +pub struct CFileProvider { pub file_callbacks: FileCallbacks, } -impl ExternalFileProvider for CFileProvder { +impl ExternalFileProvider for CFileProvider { fn open(&self) -> anyhow::Result> { let handle = (self.file_callbacks.open)(); if handle.is_null() { @@ -139,7 +139,7 @@ mod test { fn test_open() { reset_tests(); - let file_provider = CFileProvder { + let file_provider = CFileProvider { file_callbacks: FileCallbacks::new(), }; let handle = file_provider.open().unwrap(); @@ -158,7 +158,7 @@ mod test { OPEN_RET = std::ptr::null_mut(); } - let file_provider = CFileProvder { + let file_provider = CFileProvider { file_callbacks: FileCallbacks::new(), }; let result = file_provider.open(); @@ -170,7 +170,7 @@ mod test { fn test_read() { reset_tests(); - let file_provider = CFileProvder { + let file_provider = CFileProvider { file_callbacks: FileCallbacks::new(), }; let mut handle = file_provider.open().unwrap(); @@ -187,7 +187,7 @@ mod test { fn test_seek() { reset_tests(); - let file_provider = CFileProvder { + let file_provider = CFileProvider { file_callbacks: FileCallbacks::new(), }; let mut handle = file_provider.open().unwrap(); @@ -233,7 +233,7 @@ mod test { fn test_seek_err() { reset_tests(); - let file_provider = CFileProvder { + let file_provider = CFileProvider { file_callbacks: FileCallbacks::new(), }; let mut handle = file_provider.open().unwrap(); diff --git a/library/src/c_api/mod.rs b/library/src/c_api/mod.rs index 31d07521..5c553a2e 100644 --- a/library/src/c_api/mod.rs +++ b/library/src/c_api/mod.rs @@ -16,7 +16,7 @@ use std::path::PathBuf; use crate::{updater, UpdateStatus}; -use self::c_file::CFileProvder; +use self::c_file::CFileProvider; mod c_file; @@ -162,7 +162,7 @@ pub extern "C" fn shorebird_init( log_on_error( || { let config = app_config_from_c(c_params)?; - let file_provider = Box::new(CFileProvder { + let file_provider = Box::new(CFileProvider { file_callbacks: c_file_callbacks, }); let yaml_string = to_rust(c_yaml)?; diff --git a/library/src/cache/disk_io.rs b/library/src/cache/disk_io.rs index cb086c2d..cceef63a 100644 --- a/library/src/cache/disk_io.rs +++ b/library/src/cache/disk_io.rs @@ -79,7 +79,7 @@ mod test { } #[test] - fn read_errs_if_file_doesnt_exist() { + fn read_errs_if_file_does_not_exist() { assert!(super::read::(&Path::new("nonexistent.json")).is_err()); } diff --git a/library/src/cache/patch_manager.rs b/library/src/cache/patch_manager.rs index 2aa02bd1..2c713095 100644 --- a/library/src/cache/patch_manager.rs +++ b/library/src/cache/patch_manager.rs @@ -57,13 +57,14 @@ struct PatchesState { /// Abstracts the storage of patches on disk. /// -/// The impementation of this (PatchManager) should only be responsible for translating what is on -/// disk into a form that is useful for the updater and vice versa. Some business logic has crept in -/// in the form of validation, and we should consider moving that into a separate module. +/// The implementation of this (PatchManager) should only be responsible for +/// translating what is on disk into a form that is useful for the updater and +/// vice versa. Some business logic has crept in in the form of validation, and +/// we should consider moving that into a separate module. #[cfg_attr(test, automock)] pub trait ManagePatches { - /// Copies the patch file at file_path to the manager's directory structure sets - /// this patch as the next patch to boot. + /// Copies the patch file at file_path to the manager's directory structure + /// sets this patch as the next patch to boot. /// /// The explicit lifetime is required for automock to work with Options. /// See https://github.com/asomers/mockall/issues/61. @@ -952,7 +953,7 @@ mod fall_back_tests { manager.record_boot_start_for_patch(1)?; manager.record_boot_success()?; let patch_1_path = manager.patch_artifact_path(1); - std::fs::write(patch_1_path, "junkjunkjunk")?; + std::fs::write(patch_1_path, "junk junk junk")?; // Download and fall back from patch 2 manager.add_patch_for_test(&temp_dir, 2)?; diff --git a/library/src/cache/signing.rs b/library/src/cache/signing.rs index b8a95b0c..67518fd8 100644 --- a/library/src/cache/signing.rs +++ b/library/src/cache/signing.rs @@ -1,3 +1,4 @@ +// cspell:ignore pubin PKCS outform use anyhow::{bail, Context, Result}; use base64::Engine; use std::path::Path; diff --git a/library/src/network.rs b/library/src/network.rs index 859e97bf..e6186653 100644 --- a/library/src/network.rs +++ b/library/src/network.rs @@ -403,7 +403,7 @@ mod tests { let result = super::report_event_default( // Make the request to an incorrectly formatted URL, which will // trigger the same error as a lack of internet connection. - &patches_events_url("asdfasdf"), + &patches_events_url("does_not_exist"), super::CreatePatchEventRequest { event: PatchEvent { app_id: "app_id".to_string(), diff --git a/library/src/updater_lock.rs b/library/src/updater_lock.rs index 27692fca..52786059 100644 --- a/library/src/updater_lock.rs +++ b/library/src/updater_lock.rs @@ -17,12 +17,11 @@ fn updater_lock() -> &'static std::sync::Mutex { // Note: it is not OK to ever ask for the Updater lock *while* holding the // UpdateConfig lock because the updater thread *will* block on getting the -// UpdateConfig lock while holding the Updater lock. Allowing the inverse -// could cause a deadlock. We could add a check for that here by doing a -// tryLock on the UpdateConfig lock and erroring out if we can't get it, but -// that would probably have false postives since it is OK for some other call to -// be holding the UpdateConfig lock while another thread asks for the Updater -// lock. +// UpdateConfig lock while holding the Updater lock. Allowing the inverse could +// cause a deadlock. We could add a check for that here by doing a tryLock on +// the UpdateConfig lock and erroring out if we can't get it, but that would +// probably have false positives since it is OK for some other call to be +// holding the UpdateConfig lock while another thread asks for the Updater lock. pub fn with_updater_thread_lock(f: F) -> anyhow::Result where F: FnOnce(&UpdaterLockState) -> anyhow::Result, diff --git a/shorebird_code_push/CHANGELOG.md b/shorebird_code_push/CHANGELOG.md index aea447f3..7e1c8ba7 100644 --- a/shorebird_code_push/CHANGELOG.md +++ b/shorebird_code_push/CHANGELOG.md @@ -1,3 +1,13 @@ +# 2.0.2 + +- fix: un-break web platform +- chore: minor improvements to example + +# 2.0.1 + +- Update the minimum Flutter version from 3.24.4 to 3.24.5 (3.24.4 does not + include the updater changes required to support the new API). + # 2.0.0 - **BREAKING**: more updates to the Updater API. We now support Stable, Beta, diff --git a/shorebird_code_push/example/.metadata b/shorebird_code_push/example/.metadata index 30d90a7e..e9e5b3b3 100644 --- a/shorebird_code_push/example/.metadata +++ b/shorebird_code_push/example/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: 796c8ef79279f9c774545b3771238c3098dbefab - channel: stable + revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668" + channel: "stable" project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 796c8ef79279f9c774545b3771238c3098dbefab - base_revision: 796c8ef79279f9c774545b3771238c3098dbefab - - platform: android - create_revision: 796c8ef79279f9c774545b3771238c3098dbefab - base_revision: 796c8ef79279f9c774545b3771238c3098dbefab - - platform: ios - create_revision: 796c8ef79279f9c774545b3771238c3098dbefab - base_revision: 796c8ef79279f9c774545b3771238c3098dbefab - - platform: linux - create_revision: 796c8ef79279f9c774545b3771238c3098dbefab - base_revision: 796c8ef79279f9c774545b3771238c3098dbefab - - platform: macos - create_revision: 796c8ef79279f9c774545b3771238c3098dbefab - base_revision: 796c8ef79279f9c774545b3771238c3098dbefab + create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 + base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 - platform: web - create_revision: 796c8ef79279f9c774545b3771238c3098dbefab - base_revision: 796c8ef79279f9c774545b3771238c3098dbefab - - platform: windows - create_revision: 796c8ef79279f9c774545b3771238c3098dbefab - base_revision: 796c8ef79279f9c774545b3771238c3098dbefab + create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 + base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668 # User provided section diff --git a/shorebird_code_push/example/pubspec.yaml b/shorebird_code_push/example/pubspec.yaml index 73c11edf..22feb9ac 100644 --- a/shorebird_code_push/example/pubspec.yaml +++ b/shorebird_code_push/example/pubspec.yaml @@ -2,10 +2,11 @@ name: shorebird_code_push_example description: An example demonstrating how to use the shorebird_code_push package publish_to: "none" -version: 1.0.0+21 +version: 1.0.0+1 environment: - sdk: ">=3.0.5 <4.0.0" + sdk: ">=3.5.4 <4.0.0" + flutter: ">=3.24.5" dependencies: flutter: diff --git a/shorebird_code_push/example/web/index.html b/shorebird_code_push/example/web/index.html index be820e83..1aa025dd 100644 --- a/shorebird_code_push/example/web/index.html +++ b/shorebird_code_push/example/web/index.html @@ -31,29 +31,8 @@ example - - - - - + diff --git a/shorebird_code_push/lib/src/shorebird_updater.dart b/shorebird_code_push/lib/src/shorebird_updater.dart index 9329282d..fa5dbf8d 100644 --- a/shorebird_code_push/lib/src/shorebird_updater.dart +++ b/shorebird_code_push/lib/src/shorebird_updater.dart @@ -1,6 +1,5 @@ import 'package:shorebird_code_push/src/shorebird_updater_io.dart' if (dart.library.js_interop) './shorebird_updater_web.dart'; -import 'package:shorebird_code_push/src/updater.dart'; /// The reason a call to [ShorebirdUpdater.update] failed. enum UpdateFailureReason { @@ -95,7 +94,7 @@ enum UpdateStatus { /// {@endtemplate} abstract class ShorebirdUpdater { /// {@macro shorebird_updater} - factory ShorebirdUpdater() => ShorebirdUpdaterImpl(const Updater()); + factory ShorebirdUpdater() => ShorebirdUpdaterImpl(); /// Whether the updater is available on the current platform. /// The most common reasons for this returning false are: diff --git a/shorebird_code_push/lib/src/shorebird_updater_io.dart b/shorebird_code_push/lib/src/shorebird_updater_io.dart index b41df0a4..53f86552 100644 --- a/shorebird_code_push/lib/src/shorebird_updater_io.dart +++ b/shorebird_code_push/lib/src/shorebird_updater_io.dart @@ -21,8 +21,9 @@ typedef IsolateRun = Future Function( /// {@endtemplate} class ShorebirdUpdaterImpl implements ShorebirdUpdater { /// {@macro shorebird_updater_io} - ShorebirdUpdaterImpl(this._updater, {IsolateRun? run}) - : _run = run ?? Isolate.run { + ShorebirdUpdaterImpl({Updater? updater, IsolateRun? run}) + : _updater = updater ?? const Updater(), + _run = run ?? Isolate.run { try { // If the Shorebird Engine is not available, this will throw an exception. // FIXME: Run this in an isolate or refactor the updater to avoid risking diff --git a/shorebird_code_push/lib/src/shorebird_updater_web.dart b/shorebird_code_push/lib/src/shorebird_updater_web.dart index 8deb040a..509e3b2b 100644 --- a/shorebird_code_push/lib/src/shorebird_updater_web.dart +++ b/shorebird_code_push/lib/src/shorebird_updater_web.dart @@ -1,18 +1,14 @@ import 'package:shorebird_code_push/src/shorebird_updater.dart'; -import 'package:shorebird_code_push/src/updater.dart'; /// {@template shorebird_updater_web} /// The Shorebird web updater. /// {@endtemplate} class ShorebirdUpdaterImpl implements ShorebirdUpdater { /// {@macro shorebird_updater_web} - ShorebirdUpdaterImpl(this._updater) { + ShorebirdUpdaterImpl() { logShorebirdEngineUnavailableMessage(); } - // ignore: unused_field - final Updater _updater; - @override bool get isAvailable => false; diff --git a/shorebird_code_push/pubspec.yaml b/shorebird_code_push/pubspec.yaml index ca749550..dfdc3112 100644 --- a/shorebird_code_push/pubspec.yaml +++ b/shorebird_code_push/pubspec.yaml @@ -1,12 +1,12 @@ name: shorebird_code_push description: Check for and download Shorebird code push updates from your app. -version: 2.0.0 +version: 2.0.2 homepage: https://shorebird.dev repository: https://github.com/shorebirdtech/updater/tree/main/shorebird_code_push environment: sdk: ">=3.5.4 <4.0.0" - flutter: ">=3.24.4" + flutter: ">=3.24.5" dependencies: ffi: ^2.0.2 diff --git a/shorebird_code_push/test/src/shorebird_updater_io_test.dart b/shorebird_code_push/test/src/shorebird_updater_io_test.dart index 84f683af..e5ae5956 100644 --- a/shorebird_code_push/test/src/shorebird_updater_io_test.dart +++ b/shorebird_code_push/test/src/shorebird_updater_io_test.dart @@ -37,7 +37,7 @@ void main() { group('when updater is available', () { setUp(() { when(updater.currentPatchNumber).thenReturn(1); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns true', () { @@ -53,7 +53,7 @@ void main() { test( 'returns false', overridePrint((_) { - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); expect(shorebirdUpdater.isAvailable, isFalse); }), ); @@ -69,7 +69,7 @@ void main() { test( 'returns null', overridePrint((_) async { - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); await expectLater( shorebirdUpdater.readCurrentPatch(), completion(isNull), @@ -86,7 +86,7 @@ void main() { setUp(() { when(updater.currentPatchNumber).thenReturn(0); when(updater.nextPatchNumber).thenReturn(0); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns null', () async { @@ -107,7 +107,7 @@ void main() { setUp(() { when(updater.currentPatchNumber).thenReturn(currentPatchNumber); when(updater.nextPatchNumber).thenReturn(nextPatchNumber); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns correct patch numbers', () async { @@ -134,7 +134,7 @@ void main() { setUp(() { when(updater.currentPatchNumber).thenReturn(currentPatchNumber); when(updater.nextPatchNumber).thenReturn(nextPatchNumber); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns correct patch numbers', () async { @@ -169,7 +169,7 @@ void main() { setUp(() { when(updater.currentPatchNumber).thenReturn(currentPatchNumber); when(updater.nextPatchNumber).thenReturn(nextPatchNumber); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns correct patch numbers', () async { @@ -205,7 +205,7 @@ void main() { return value; }); when(updater.nextPatchNumber).thenThrow(Exception('oops')); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws $ReadPatchException', () async { @@ -230,7 +230,7 @@ void main() { test( 'returns UpdateStatus.unavailable', overridePrint((_) async { - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); await expectLater( shorebirdUpdater.checkForUpdate(), completion(equals(UpdateStatus.unavailable)), @@ -243,7 +243,7 @@ void main() { setUp(() { when(updater.currentPatchNumber).thenReturn(0); when(updater.checkForDownloadableUpdate).thenReturn(true); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns UpdateStatus.outdated', () async { @@ -259,7 +259,7 @@ void main() { when(updater.currentPatchNumber).thenReturn(0); when(updater.nextPatchNumber).thenReturn(1); when(updater.checkForDownloadableUpdate).thenReturn(false); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns UpdateStatus.restartRequired', () async { @@ -275,7 +275,7 @@ void main() { when(updater.currentPatchNumber).thenReturn(1); when(updater.nextPatchNumber).thenReturn(1); when(updater.checkForDownloadableUpdate).thenReturn(false); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('returns UpdateStatus.upToDate', () async { @@ -294,7 +294,7 @@ void main() { when( () => updater.checkForDownloadableUpdate(track: track), ).thenReturn(true); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('forwards the provided track to the underlying updater call', @@ -318,7 +318,7 @@ void main() { test( 'does nothing', overridePrint((_) async { - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); await expectLater(shorebirdUpdater.update(), completes); verifyNever(updater.downloadUpdate); }), @@ -329,7 +329,7 @@ void main() { setUp(() { when(() => updater.currentPatchNumber()).thenReturn(0); when(() => updater.update()).thenReturn(nullptr); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws $UpdateException', () async { @@ -365,7 +365,7 @@ void main() { ..free(result); }); when(() => updater.update()).thenReturn(result); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws $UpdateException', () async { @@ -402,7 +402,7 @@ void main() { ..free(result); }); when(() => updater.update()).thenReturn(result); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws $UpdateException', () async { @@ -439,7 +439,7 @@ void main() { ..free(result); }); when(() => updater.update()).thenReturn(result); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws $UpdateException', () async { @@ -467,7 +467,7 @@ void main() { result.ref.status = SHOREBIRD_UPDATE_ERROR; addTearDown(() => calloc.free(result)); when(() => updater.update()).thenReturn(result); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws $UpdateException', () async { @@ -497,7 +497,7 @@ void main() { when(updater.currentPatchNumber).thenReturn(0); when(updater.nextPatchNumber).thenReturn(1); when(() => updater.update()).thenThrow(Exception('oops')); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('falls back to downloadUpdate', () async { @@ -511,7 +511,7 @@ void main() { setUp(() { when(updater.currentPatchNumber).thenReturn(0); when(updater.nextPatchNumber).thenReturn(0); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws if legacy update fails', () async { @@ -546,7 +546,7 @@ Please upgrade the Shorebird Engine for improved error messages.''', result.ref.message = nullptr; addTearDown(() => calloc.free(result)); when(() => updater.update()).thenReturn(result); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('throws $UpdateException', () async { @@ -578,7 +578,7 @@ Please upgrade the Shorebird Engine for improved error messages.''', result.ref.status = SHOREBIRD_UPDATE_INSTALLED; addTearDown(() => calloc.free(result)); when(() => updater.update()).thenReturn(result); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('completes', () async { @@ -597,7 +597,7 @@ Please upgrade the Shorebird Engine for improved error messages.''', result.ref.status = SHOREBIRD_UPDATE_INSTALLED; addTearDown(() => calloc.free(result)); when(() => updater.update(track: track)).thenReturn(result); - shorebirdUpdater = ShorebirdUpdaterImpl(updater, run: run); + shorebirdUpdater = ShorebirdUpdaterImpl(updater: updater, run: run); }); test('forwards the provided track to the underlying updater call', diff --git a/shorebird_code_push/test/src/shorebird_updater_web_test.dart b/shorebird_code_push/test/src/shorebird_updater_web_test.dart index 6bdcbb5a..bc7270a6 100644 --- a/shorebird_code_push/test/src/shorebird_updater_web_test.dart +++ b/shorebird_code_push/test/src/shorebird_updater_web_test.dart @@ -1,26 +1,17 @@ -import 'package:mocktail/mocktail.dart'; import 'package:shorebird_code_push/src/shorebird_updater.dart'; import 'package:shorebird_code_push/src/shorebird_updater_web.dart'; -import 'package:shorebird_code_push/src/updater.dart'; import 'package:test/test.dart'; import '../override_print.dart'; -class _MockUpdater extends Mock implements Updater {} - void main() { group(ShorebirdUpdaterImpl, () { - late Updater updater; late ShorebirdUpdaterImpl shorebirdUpdater; - setUp(() { - updater = _MockUpdater(); - }); - test( 'logs unavailable error', overridePrint((logs) { - shorebirdUpdater = ShorebirdUpdaterImpl(updater); + shorebirdUpdater = ShorebirdUpdaterImpl(); expect( logs, contains( @@ -40,7 +31,7 @@ void main() { test( 'returns false', overridePrint((_) { - shorebirdUpdater = ShorebirdUpdaterImpl(updater); + shorebirdUpdater = ShorebirdUpdaterImpl(); expect(shorebirdUpdater.isAvailable, isFalse); }), ); @@ -79,7 +70,6 @@ void main() { 'does nothing', overridePrint((_) async { await expectLater(shorebirdUpdater.update(), completes); - verifyNever(updater.downloadUpdate); }), ); });