ci: serial flutter unit test (#1814)

This commit is contained in:
Nathan.fooo
2023-02-07 10:48:28 +08:00
committed by GitHub
parent e2f6f68923
commit 5f760ad578
6 changed files with 36 additions and 19 deletions

View File

@ -10,7 +10,9 @@ import 'notification_helper.dart';
// Folder // Folder
typedef FolderNotificationCallback = void Function( typedef FolderNotificationCallback = void Function(
FolderNotification, Either<Uint8List, FlowyError>); FolderNotification,
Either<Uint8List, FlowyError>,
);
class FolderNotificationParser class FolderNotificationParser
extends NotificationParser<FolderNotification, FlowyError> { extends NotificationParser<FolderNotification, FlowyError> {
@ -25,15 +27,21 @@ class FolderNotificationParser
} }
typedef FolderNotificationHandler = Function( typedef FolderNotificationHandler = Function(
FolderNotification ty, Either<Uint8List, FlowyError> result); FolderNotification ty,
Either<Uint8List, FlowyError> result,
);
class FolderNotificationListener { class FolderNotificationListener {
StreamSubscription<SubscribeObject>? _subscription; StreamSubscription<SubscribeObject>? _subscription;
FolderNotificationParser? _parser; FolderNotificationParser? _parser;
FolderNotificationListener( FolderNotificationListener({
{required String objectId, required FolderNotificationHandler handler}) required String objectId,
: _parser = FolderNotificationParser(id: objectId, callback: handler) { required FolderNotificationHandler handler,
}) : _parser = FolderNotificationParser(
id: objectId,
callback: handler,
) {
_subscription = _subscription =
RustStreamReceiver.listen((observable) => _parser?.parse(observable)); RustStreamReceiver.listen((observable) => _parser?.parse(observable));
} }

View File

@ -10,7 +10,9 @@ import 'notification_helper.dart';
// DatabasePB // DatabasePB
typedef DatabaseNotificationCallback = void Function( typedef DatabaseNotificationCallback = void Function(
DatabaseNotification, Either<Uint8List, FlowyError>); DatabaseNotification,
Either<Uint8List, FlowyError>,
);
class DatabaseNotificationParser class DatabaseNotificationParser
extends NotificationParser<DatabaseNotification, FlowyError> { extends NotificationParser<DatabaseNotification, FlowyError> {
@ -31,9 +33,10 @@ class DatabaseNotificationListener {
StreamSubscription<SubscribeObject>? _subscription; StreamSubscription<SubscribeObject>? _subscription;
DatabaseNotificationParser? _parser; DatabaseNotificationParser? _parser;
DatabaseNotificationListener( DatabaseNotificationListener({
{required String objectId, required DatabaseNotificationHandler handler}) required String objectId,
: _parser = DatabaseNotificationParser(id: objectId, callback: handler) { required DatabaseNotificationHandler handler,
}) : _parser = DatabaseNotificationParser(id: objectId, callback: handler) {
_subscription = _subscription =
RustStreamReceiver.listen((observable) => _parser?.parse(observable)); RustStreamReceiver.listen((observable) => _parser?.parse(observable));
} }

View File

@ -10,7 +10,9 @@ import 'notification_helper.dart';
// User // User
typedef UserNotificationCallback = void Function( typedef UserNotificationCallback = void Function(
UserNotification, Either<Uint8List, FlowyError>); UserNotification,
Either<Uint8List, FlowyError>,
);
class UserNotificationParser class UserNotificationParser
extends NotificationParser<UserNotification, FlowyError> { extends NotificationParser<UserNotification, FlowyError> {
@ -31,9 +33,10 @@ class UserNotificationListener {
StreamSubscription<SubscribeObject>? _subscription; StreamSubscription<SubscribeObject>? _subscription;
UserNotificationParser? _parser; UserNotificationParser? _parser;
UserNotificationListener( UserNotificationListener({
{required String objectId, required UserNotificationHandler handler}) required String objectId,
: _parser = UserNotificationParser(id: objectId, callback: handler) { required UserNotificationHandler handler,
}) : _parser = UserNotificationParser(id: objectId, callback: handler) {
_subscription = _subscription =
RustStreamReceiver.listen((observable) => _parser?.parse(observable)); RustStreamReceiver.listen((observable) => _parser?.parse(observable));
} }

View File

@ -9,7 +9,8 @@ import 'package:appflowy_backend/protobuf/flowy-folder/trash.pb.dart';
import 'package:appflowy_backend/rust_stream.dart'; import 'package:appflowy_backend/rust_stream.dart';
typedef TrashUpdatedCallback = void Function( typedef TrashUpdatedCallback = void Function(
Either<List<TrashPB>, FlowyError> trashOrFailed); Either<List<TrashPB>, FlowyError> trashOrFailed,
);
class TrashListener { class TrashListener {
StreamSubscription<SubscribeObject>? _subscription; StreamSubscription<SubscribeObject>? _subscription;
@ -24,7 +25,9 @@ class TrashListener {
} }
void _observableCallback( void _observableCallback(
FolderNotification ty, Either<Uint8List, FlowyError> result) { FolderNotification ty,
Either<Uint8List, FlowyError> result,
) {
switch (ty) { switch (ty) {
case FolderNotification.TrashUpdated: case FolderNotification.TrashUpdated:
if (_trashUpdated != null) { if (_trashUpdated != null) {

View File

@ -23,7 +23,7 @@ class RustStreamReceiver {
_observableController = StreamController.broadcast(); _observableController = StreamController.broadcast();
_ffiPort.handler = _streamController.add; _ffiPort.handler = _streamController.add;
_ffiSubscription = _streamController.stream.listen(streamCallback); _ffiSubscription = _streamController.stream.listen(_streamCallback);
} }
factory RustStreamReceiver() { factory RustStreamReceiver() {
@ -35,7 +35,7 @@ class RustStreamReceiver {
return RustStreamReceiver.shared.observable.stream.listen(callback); return RustStreamReceiver.shared.observable.stream.listen(callback);
} }
void streamCallback(Uint8List bytes) { void _streamCallback(Uint8List bytes) {
try { try {
final observable = SubscribeObject.fromBuffer(bytes); final observable = SubscribeObject.fromBuffer(bytes);
_observableController.add(observable); _observableController.add(observable);

View File

@ -18,12 +18,12 @@ cargo make --profile test-linux dart_unit_test_inner
script_runner = "@shell" script_runner = "@shell"
[tasks.dart_unit_test_inner] [tasks.dart_unit_test_inner]
env = { RUST_LOG = "info" } env = { RUST_LOG = "info", TEST_RUST_LOG = "info" }
dependencies = ["build-test-lib"] dependencies = ["build-test-lib"]
description = "Run flutter unit tests" description = "Run flutter unit tests"
script = ''' script = '''
cd app_flowy cd app_flowy
flutter test --dart-define=RUST_LOG=${TEST_RUST_LOG} --concurrency=1 flutter test --dart-define=RUST_LOG=${TEST_RUST_LOG} -j, --concurrency=1
''' '''
[tasks.rust_unit_test] [tasks.rust_unit_test]