atn832 / fake_cloud_firestore

BSD 2-Clause "Simplified" License
119 stars 93 forks source link

MockFirestoreInstance.dump() crashes on GeoPoint #35

Closed atn832 closed 1 year ago

atn832 commented 4 years ago

This test fails:

await firebase.collection('places').add({
  location: GeoPoint(10, 100)
});
final snapshot = await firebase.collection('places').getDocuments();
final document = snapshot.documents.first;
expect(document['location'], equals(GeoPoint(10, 100)); // this works
expect(firebase.dump(), contains('location: ...')); // this does not.
atn832 commented 4 years ago

It actually throws this error:

  Converting object to an encodable object failed: Instance of 'GeoPoint'
  dart:convert                                                             JsonEncoder.convert
  package:cloud_firestore_mocks/src/cloud_firestore_mocks_base.dart 39:30  MockFirestoreInstance.dump
pooja96km commented 4 years ago

Have you found a solution to this issue?

atn832 commented 4 years ago

The solution is to handle GeoPoint at https://github.com/atn832/cloud_firestore_mocks/blob/1b556fb34c02d18488f6f120f4d3808e0e5dc6cd/lib/src/util.dart#L41. I haven't had the time to handle it so far. If you need it urgently, feel free to contribute a PR and I'll be happy to review it.

gaburielcasado commented 1 year ago

@atn832 I created a PR (https://github.com/atn832/fake_cloud_firestore/pull/257) to handle this. Please let me know if that's acceptable

atn832 commented 1 year ago

I forgot to mention it, but I published your fix in version 2.2.0 last week: https://pub.dev/packages/fake_cloud_firestore/changelog#220. Thanks for taking care of this long-standing issue!