Skip to content

Commit

Permalink
test: check exception thrown from a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Jan 15, 2025
1 parent c04dc55 commit c89f79f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sqflite_common_test/lib/transaction_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -496,5 +496,22 @@ void run(SqfliteTestContext context) {
await db.close();
}
});
test('throw in transaction', () async {
var path = await context.initDeleteDb('throw_in_transaction.db');

Object? exception;
var db = await factory.openDatabase(path);
try {
await db.transaction((txn) async {
throw _MyException();
});
} on _MyException catch (e) {
exception = e;
}
// Check that the exception has been thrown
expect(exception, isA<_MyException>());
});
});
}

class _MyException {}

0 comments on commit c89f79f

Please sign in to comment.