Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
wip #377
  • Loading branch information
zin- committed Sep 7, 2024
1 parent 63a1cf9 commit 6ecb40d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions lib/framework/repository/key_with_value_repository.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:mem/framework/repository/key_with_value.dart';
import 'package:mem/framework/repository/repository.dart';

abstract class KeyWithValueRepositoryV2<
ENTITY extends KeyWithValue<KEY, dynamic>,
abstract class KeyWithValueRepository<ENTITY extends KeyWithValue<KEY, dynamic>,
KEY> extends Repository<ENTITY> {
Future<void> receive(ENTITY entity);
Future<void> receive(ENTITY entity) => throw UnimplementedError();

Future<void> discard(KEY key);
Future<void> discard(KEY key) => throw UnimplementedError();

Future<void> discardAll();
Future<void> discardAll() => throw UnimplementedError();
}
2 changes: 1 addition & 1 deletion lib/notifications/notification_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'notification/notification.dart';
import 'flutter_local_notifications_wrapper.dart';

class NotificationRepository
extends KeyWithValueRepositoryV2<NotificationV2, int> {
extends KeyWithValueRepository<NotificationV2, int> {
final FlutterLocalNotificationsWrapper? _flutterLocalNotificationsWrapper =
defaultTargetPlatform == TargetPlatform.android
? FlutterLocalNotificationsWrapper(androidDefaultIconPath)
Expand Down
2 changes: 2 additions & 0 deletions lib/settings/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Future<void> update<Key extends PreferenceKey<Value>, Value>(
) =>
v(
() async => await (value == null
// coverage:ignore-start
? _client.discard(key)
// coverage:ignore-end
: _client.receive(PreferenceEntity(key, value))),
{
'key': key,
Expand Down
5 changes: 1 addition & 4 deletions lib/settings/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:mem/settings/preference_key.dart';
import 'package:shared_preferences/shared_preferences.dart';

class PreferenceClientRepository
extends KeyWithValueRepositoryV2<PreferenceEntity, PreferenceKey> {
extends KeyWithValueRepository<PreferenceEntity, PreferenceKey> {
Future<PreferenceEntity<T>> shipByKey<T>(PreferenceKey<T> key) => v(
() async {
final saved = (await SharedPreferences.getInstance()).get(key.value);
Expand Down Expand Up @@ -42,7 +42,4 @@ class PreferenceClientRepository
() async => (await SharedPreferences.getInstance()).remove(key.value),
{'key': key},
);

@override
Future<void> discardAll() => throw UnimplementedError();
}

0 comments on commit 6ecb40d

Please sign in to comment.