mirror of https://github.com/AMT-Cheif/drift.git
Add tests for errors across isolates
This commit is contained in:
parent
d881659db6
commit
b4aeacdba3
|
@ -147,7 +147,7 @@ class IsolateCommunication {
|
|||
|
||||
/// Sends an erroneous response for a [Request].
|
||||
void respondError(Request request, dynamic error, [StackTrace trace]) {
|
||||
// sending a message while closed with throw, so don't even try.
|
||||
// sending a message while closed will throw, so don't even try.
|
||||
if (isClosed) return;
|
||||
|
||||
_send(_ErrorResponse(request.id, error.toString(), trace.toString()));
|
||||
|
|
|
@ -59,6 +59,25 @@ void main() {
|
|||
await expectation;
|
||||
await moorIsolate.shutdownAll();
|
||||
});
|
||||
|
||||
test('errors propagate across isolates', () async {
|
||||
final isolate = await MoorIsolate.spawn(_backgroundConnection);
|
||||
final db = TodoDb.connect(await isolate.connect());
|
||||
|
||||
await expectLater(
|
||||
() => db.customStatement('UPDATE non_existing_table SET foo = bar'),
|
||||
throwsA(anything),
|
||||
);
|
||||
|
||||
// Check that isolate is still usable
|
||||
await expectLater(
|
||||
db.customSelect('SELECT 1').get(),
|
||||
completion(isNotEmpty),
|
||||
);
|
||||
|
||||
await db.close();
|
||||
await isolate.shutdownAll();
|
||||
});
|
||||
}
|
||||
|
||||
void _runTests(
|
||||
|
|
Loading…
Reference in New Issue