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
Add support for throwing exceptions on get(), update() and delete() #275
Conversation
Thanks for the PR @mrunix00! Interestingly, it works even on a different reference: // Works on the same reference.
expect(() => doc.set({'name': 'Bob'}), throwsA(isA<FirebaseException>()));
// Works on a different reference of the same document.
expect(() => instance.collection('users').doc(uid).set({'name': 'Bob'}),
throwsA(isA<FirebaseException>())); It's probably luck and how Object.hashcode is implemented. Just to be sure, I'll explicitly implement hashcode in a separate PR. |
However, it does not work for Queries: final movies = firestore.collection('movies');
final query = firestore
.collection('movies')
.where('title', isEqualTo: 'Test Movie');
await movies.add({
'title': 'Test Movie',
});
whenCalling(Invocation.method(#get, null))
.on(query)
.thenThrow(FirebaseException(plugin: 'firestore'));
// this throws the exception correctly.
whenCalling(Invocation.method(#get, null))
.on(query)
.thenThrow(FirebaseException(plugin: 'firestore'));
// but this does not throw the exception.
expect(
() async => await firestore
.collection('movies')
.where('title', isEqualTo: 'Test Movie')
.get(GetOptions(source: Source.server)),
throwsA(isA<FirebaseException>()),
); |
Just uploaded your PR to version 2.4.3. Thanks again! https://pub.dev/packages/fake_cloud_firestore/changelog#243 |
Yeah I just noticed that lately, I'll try to find a good fix for that |
I debugged a bit earlier, and it seemed that when we call |
Fixes #272