Skip to content

Commit

Permalink
test fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
Equartey committed Nov 20, 2024
1 parent a7213b2 commit 8276de3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
timeout-minutes: 60
run: |
flutter config --enable-windows-desktop
dart pub global run aft exec --include=${{ inputs.package-name }} -- flutter test integration_test/main_test.dart -d windows
dart pub global run aft exec --include=${{ inputs.package-name }} -- flutter test integration_test/main_test.dart -d windows --timeout=120
- name: Log success/failure
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ void main() {
});

testWidgets('can decrement', (_) async {
print('Running "can decrement" test');
expect(await db.getLatestCount(), 0);
await Future.wait<void>([
for (var i = 0; i < 10; i++) db.decrementCount(),
]);
expect(await db.getLatestCount(), -10);
print('"can decrement" test passed');
});

testWidgets('can increment', (_) async {
Expand Down
25 changes: 19 additions & 6 deletions packages/common/amplify_db_common_dart/lib/src/connect_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ QueryExecutor connect({
_IsolateStartRequest(receiveDriftIsolate.sendPort, dbPath),
);

final driftIsolate = await receiveDriftIsolate.first as DriftIsolate;
final driftIsolateOrError = await receiveDriftIsolate.first;

if (driftIsolateOrError is Map &&
driftIsolateOrError.containsKey('error')) {
throw Exception(
'Error in isolate: ${driftIsolateOrError['message']}}',
);
}

final driftIsolate = driftIsolateOrError as DriftIsolate;
return driftIsolate.connect();
}),
).executor;
Expand All @@ -47,11 +56,15 @@ class _IsolateStartRequest {
}

void _entrypointForDriftIsolate(_IsolateStartRequest request) {
final databaseImpl = NativeDatabase(File(request.databasePath));
try {
final databaseImpl = NativeDatabase(File(request.databasePath));

final driftServer = DriftIsolate.inCurrent(
() => DatabaseConnection(databaseImpl),
);
final driftServer = DriftIsolate.inCurrent(
() => DatabaseConnection(databaseImpl),
);

request.talkToMain.send(driftServer);
request.talkToMain.send(driftServer);
} catch (e, stack) {
request.talkToMain.send({'error': e.toString(), 'stack': stack.toString()});
}
}

0 comments on commit 8276de3

Please sign in to comment.