Skip to content

Commit

Permalink
fix: Analyze Test code
Browse files Browse the repository at this point in the history
wip #377
  • Loading branch information
zin- committed Sep 7, 2024
1 parent 6ecb40d commit 33945a9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 61 deletions.
28 changes: 13 additions & 15 deletions integration_test/framework/database_tuple_repository_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,19 @@ void main() => group(
},
);

test(
': updated.',
() async {
final updatedAt = DateTime.now();
final updating = savedFalseSample.copiedWith(
a: () => true,
);

final updated = await repository.replace(updating,
updatedAt: updatedAt);

expect(updated.a, equals(updating.a));
expect(updated.updatedAt, equals(updatedAt));
},
);
test(': updated.', () async {
final updatedAt = DateTime.now();
final updating = TestObjectDatabaseTupleEntity.fromMap(
savedFalseSample.toMap
..update(
TestObjectEntity.fieldNames[0], (value) => false));

final updated =
await repository.replace(updating, updatedAt: updatedAt);

expect(updated.a, equals(updating.a));
expect(updated.updatedAt, equals(updatedAt));
});
},
);

Expand Down
9 changes: 6 additions & 3 deletions lib/framework/repository/key_with_value_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import 'package:mem/framework/repository/repository.dart';

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

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

Future<void> discardAll() => throw UnimplementedError();
mixin DiscardAll<ENTITY extends KeyWithValue<KEY, dynamic>, KEY>
on KeyWithValueRepository<ENTITY, KEY> {
Future<void> discardAll();
}
4 changes: 2 additions & 2 deletions lib/notifications/notification_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'package:mem/values/paths.dart';
import 'notification/notification.dart';
import 'flutter_local_notifications_wrapper.dart';

class NotificationRepository
extends KeyWithValueRepository<NotificationV2, int> {
class NotificationRepository extends KeyWithValueRepository<NotificationV2, int>
with DiscardAll {
final FlutterLocalNotificationsWrapper? _flutterLocalNotificationsWrapper =
defaultTargetPlatform == TargetPlatform.android
? FlutterLocalNotificationsWrapper(androidDefaultIconPath)
Expand Down
26 changes: 0 additions & 26 deletions test/framework/repository/database_tuple_entity_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class TestObjectDatabaseTupleEntity extends TestObjectEntity
: super.fromMap(map) {
withMap(map);
}

@override
TestObjectDatabaseTupleEntity copiedWith({bool Function()? a}) =>
TestObjectDatabaseTupleEntity.fromMap(
toMap..addAll(super.copiedWith(a: a).toMap));
}

void main() => group(
Expand Down Expand Up @@ -68,26 +63,5 @@ void main() => group(
expect(testObject.toMap, map);
},
);

test(
'#copiedWith',
() {
final from = TestObjectDatabaseTupleEntity.fromMap({
TestObjectEntity.fieldNames[0]: false,
defPkId.name: 1,
defColCreatedAt.name: DateTime.now(),
defColUpdatedAt.name: DateTime.now(),
defColArchivedAt.name: DateTime.now()
});

final copied = from.copiedWith(a: () => true);

expect(copied.a, equals(true));
expect(copied.id, equals(from.id));
expect(copied.createdAt, equals(from.createdAt));
expect(copied.updatedAt, equals(from.updatedAt));
expect(copied.archivedAt, equals(from.archivedAt));
},
);
},
);
15 changes: 0 additions & 15 deletions test/framework/repository/entity_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class TestObjectEntity extends _TestObject with Entity {

@override
Map<String, dynamic> get toMap => {fieldNames[0]: a};

@override
TestObjectEntity copiedWith({bool Function()? a}) =>
TestObjectEntity(a == null ? this.a : a());
}

void main() => group(
Expand Down Expand Up @@ -74,16 +70,5 @@ void main() => group(
expect(testObjectA, equals(testObjectB));
},
);

test(
'#copiedWith',
() {
final from = TestObjectEntity(false);

final copied = from.copiedWith(a: () => true);

expect(copied.a, equals(true));
},
);
},
);

0 comments on commit 33945a9

Please sign in to comment.