Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction does not revert if an error occurs #271

Open
ANDREYDEN opened this issue Jul 14, 2023 · 1 comment
Open

Transaction does not revert if an error occurs #271

ANDREYDEN opened this issue Jul 14, 2023 · 1 comment

Comments

@ANDREYDEN
Copy link

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);
  }
});
@monkeydaichan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants