Fixed failing tests due to the change from Events to events collection name

This commit is contained in:
Mariano Uvalle 2019-04-04 01:37:09 -06:00
parent f3872944ee
commit 9a13781052
2 changed files with 10 additions and 10 deletions

View file

@ -223,7 +223,7 @@ class FirestoreProvider {
Future<void> addEvent(String userId, EventModel event) async {
try {
final dataMap = event.toFirestoreMap();
await _firestore.collection('users/$userId/Events').add(dataMap);
await _firestore.collection('users/$userId/events').add(dataMap);
// After the event was added successfully we have to update the events a
// user has.
final user = await getUser(id: userId);
@ -237,7 +237,7 @@ class FirestoreProvider {
/// Returns a Stream of a single event.
Observable<EventModel> getEventObservable(String userId, String eventId) {
final mappedStream = _firestore
.collection('users/$userId/Events')
.collection('users/$userId/events')
.document(eventId)
.snapshots()
.map(
@ -282,7 +282,7 @@ class FirestoreProvider {
Future<void> deleteEvent(String userId, String eventId) async {
try {
final documentReference =
_firestore.document('users/$userId/Events/$eventId');
_firestore.document('users/$userId/events/$eventId');
await documentReference.delete();
} catch (e) {
print('Error deleting event in firestore: $e');
@ -334,7 +334,7 @@ class FirestoreProvider {
/// a particular user.
Observable<List<EventModel>> getUserEvents(String userId) {
final mappedStream =
_firestore.collection('users/$userId/Events').snapshots().map(
_firestore.collection('users/$userId/events').snapshots().map(
(QuerySnapshot snapshot) {
return snapshot.documents.map((DocumentSnapshot documentSnapshot) {
return EventModel.fromFirestore(

View file

@ -190,7 +190,7 @@ main() {
final collection = MockCollectionReference();
final provider = FirestoreProvider(firestore);
when(firestore.collection('users/123/Events')).thenReturn(collection);
when(firestore.collection('users/123/events')).thenReturn(collection);
provider.addEvent('123', event);
@ -205,12 +205,12 @@ main() {
final document = MockDocumentReference();
final provider = FirestoreProvider(firestore);
when(firestore.collection('users/123/Events')).thenReturn(collection);
when(firestore.collection('users/123/events')).thenReturn(collection);
when(collection.document(event.id)).thenReturn(document);
when(document.snapshots()).thenAnswer((_) => snapshots);
when(snapshot.documentID).thenReturn(event.id);
expectLater(provider.getEvent('123', event.id), emits(event));
expectLater(provider.getEventObservable('123', event.id), emits(event));
});
test('should delete an event', () {
@ -218,7 +218,7 @@ main() {
final document = MockDocumentReference();
final provider = FirestoreProvider(firestore);
when(firestore.document('users/123/Events/${event.id}'))
when(firestore.document('users/123/events/${event.id}'))
.thenReturn(document);
when(document.delete()).thenAnswer((_) => Future<void>.value());
@ -232,7 +232,7 @@ main() {
final document = MockDocumentReference();
final provider = FirestoreProvider(firestore);
when(firestore.document('users/123/Events/${event.id}'))
when(firestore.document('users/123/events/${event.id}'))
.thenReturn(document);
provider.updateEvent('123', event.id, name: 'new name');
@ -248,7 +248,7 @@ main() {
final document = MockDocumentSnapshot(event.toFirestoreMap());
final provider = FirestoreProvider(firestore);
when(firestore.collection('users/123/Events')).thenReturn(collection);
when(firestore.collection('users/123/events')).thenReturn(collection);
when(collection.snapshots()).thenAnswer((_) => snapshots);
when(snapshot.documents).thenReturn([document]);
when(document.documentID).thenReturn(event.id);