Skip to content

Commit c89f79f

Browse files
committedJan 15, 2025
test: check exception thrown from a transaction
1 parent c04dc55 commit c89f79f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
 

‎sqflite_common_test/lib/transaction_test.dart

+17
Original file line numberDiff line numberDiff line change
@@ -496,5 +496,22 @@ void run(SqfliteTestContext context) {
496496
await db.close();
497497
}
498498
});
499+
test('throw in transaction', () async {
500+
var path = await context.initDeleteDb('throw_in_transaction.db');
501+
502+
Object? exception;
503+
var db = await factory.openDatabase(path);
504+
try {
505+
await db.transaction((txn) async {
506+
throw _MyException();
507+
});
508+
} on _MyException catch (e) {
509+
exception = e;
510+
}
511+
// Check that the exception has been thrown
512+
expect(exception, isA<_MyException>());
513+
});
499514
});
500515
}
516+
517+
class _MyException {}

0 commit comments

Comments
 (0)