From 543df749d492eed1fa7ca1ca53a158652f7440d1 Mon Sep 17 00:00:00 2001 From: zin- Date: Sat, 31 Aug 2024 11:49:32 +0900 Subject: [PATCH] coverage wip #377 --- lib/framework/repository/key_with_value_repository.dart | 9 ++++----- lib/notifications/notification_repository.dart | 2 +- lib/settings/actions.dart | 2 ++ lib/settings/client.dart | 5 +---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/framework/repository/key_with_value_repository.dart b/lib/framework/repository/key_with_value_repository.dart index 1559f082e..a092f65ac 100644 --- a/lib/framework/repository/key_with_value_repository.dart +++ b/lib/framework/repository/key_with_value_repository.dart @@ -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, +abstract class KeyWithValueRepository, KEY> extends Repository { - Future receive(ENTITY entity); + Future receive(ENTITY entity) => throw UnimplementedError(); - Future discard(KEY key); + Future discard(KEY key) => throw UnimplementedError(); - Future discardAll(); + Future discardAll() => throw UnimplementedError(); } diff --git a/lib/notifications/notification_repository.dart b/lib/notifications/notification_repository.dart index c5589aea8..d75a4bebe 100644 --- a/lib/notifications/notification_repository.dart +++ b/lib/notifications/notification_repository.dart @@ -10,7 +10,7 @@ import 'notification/notification.dart'; import 'flutter_local_notifications_wrapper.dart'; class NotificationRepository - extends KeyWithValueRepositoryV2 { + extends KeyWithValueRepository { final FlutterLocalNotificationsWrapper? _flutterLocalNotificationsWrapper = defaultTargetPlatform == TargetPlatform.android ? FlutterLocalNotificationsWrapper(androidDefaultIconPath) diff --git a/lib/settings/actions.dart b/lib/settings/actions.dart index d130564b5..7705fcb0b 100644 --- a/lib/settings/actions.dart +++ b/lib/settings/actions.dart @@ -21,7 +21,9 @@ Future update, Value>( ) => v( () async => await (value == null +// coverage:ignore-start ? _client.discard(key) +// coverage:ignore-end : _client.receive(PreferenceEntity(key, value))), { 'key': key, diff --git a/lib/settings/client.dart b/lib/settings/client.dart index ea6ed908a..4ac0c4d5e 100644 --- a/lib/settings/client.dart +++ b/lib/settings/client.dart @@ -5,7 +5,7 @@ import 'package:mem/settings/preference_key.dart'; import 'package:shared_preferences/shared_preferences.dart'; class PreferenceClientRepository - extends KeyWithValueRepositoryV2 { + extends KeyWithValueRepository { Future> shipByKey(PreferenceKey key) => v( () async { final saved = (await SharedPreferences.getInstance()).get(key.value); @@ -42,7 +42,4 @@ class PreferenceClientRepository () async => (await SharedPreferences.getInstance()).remove(key.value), {'key': key}, ); - - @override - Future discardAll() => throw UnimplementedError(); }