Skip to content

Commit

Permalink
refactor: minor adjustments and add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Feb 7, 2025
1 parent ad1b3f5 commit 9f11315
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
6 changes: 2 additions & 4 deletions shorebird_code_push/lib/src/shorebird_updater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ class ReadPatchException implements Exception {
final String message;

@override
String toString() {
return '[ShorebirdUpdater.ReadPatchException] $message';
}
String toString() => '[ShorebirdUpdater] ReadPatchException: $message';
}

/// {@template update_exception}
Expand All @@ -49,7 +47,7 @@ class UpdateException implements Exception {

@override
String toString() {
return '[ShorebirdUpdater.UpdateException] $message';
return '[ShorebirdUpdater] UpdateException: $message (${reason.name})';
}
}

Expand Down
25 changes: 25 additions & 0 deletions shorebird_code_push/test/src/shorebird_updater_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,30 @@ void main() {
expect(ShorebirdUpdater.new, returnsNormally);
}),
);

group(UpdateException, () {
test('overrides toString', () {
const message = 'message';
const reason = UpdateFailureReason.downloadFailed;
const exception = UpdateException(message: message, reason: reason);
expect(
exception.toString(),
equals(
'[ShorebirdUpdater] UpdateException: $message (${reason.name})',
),
);
});
});

group(ReadPatchException, () {
test('overrides toString', () {
const message = 'message';
const exception = ReadPatchException(message: message);
expect(
exception.toString(),
equals('[ShorebirdUpdater] ReadPatchException: $message'),
);
});
});
});
}

0 comments on commit 9f11315

Please sign in to comment.