fake_cloud_firestore
fake_cloud_firestore copied to clipboard
Transaction does not revert if an error occurs
Failing test:
test('does not add a document if a transaction fails', () async {
final db = FakeFirebaseFirestore();
try {
await db.runTransaction((transaction) async {
transaction.set(db.collection('test').doc(), {'name': 'Jane'});
// the next line makes the transaction fail because reads should always come before writes
await transaction.get(db.collection('test').doc('non-existent'));
});
} finally {
final snapshot = await db.collection('test').get();
expect(snapshot.docs, isEmpty);
}
});
Facing same issue.
fvm doctor
% fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.3.1 22E772610a darwin-arm64, locale ja-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.80.1)
[✓] Connected device (5 available)
[✓] Network resources
• No issues found!
pubspec.yaml
dependencies:
cloud_firestore: ^4.7.1
dev_dependencies:
fake_cloud_firestore: ^2.4.1+1