Skip to content

Commit

Permalink
[cloud_firestore] fix NoSuchMethodError regression and add test (flut…
Browse files Browse the repository at this point in the history
…ter#1345)

Fix cloud_firestore regression and add test
  • Loading branch information
collinjackson authored Mar 15, 2019
1 parent 04516a9 commit 6aef375
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/cloud_firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.9.7

* Fixes a NoSuchMethodError when using getDocuments on iOS (introduced in 0.9.6).
* Adds a driver test for getDocuments.

## 0.9.6

* On iOS, update null checking to match the recommended pattern usage in the Firebase documentation.
Expand Down
5 changes: 5 additions & 0 deletions packages/cloud_firestore/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ dependencies:
path: ../
firebase_core: "^0.3.0"

dev_dependencies:
flutter_driver:
sdk: flutter
test: any

flutter:
uses-material-design: true
34 changes: 34 additions & 0 deletions packages/cloud_firestore/example/test_driver/cloud_firestore.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'dart:async';
import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';

void main() {
final Completer<String> completer = Completer<String>();
enableFlutterDriverExtension(handler: (_) => completer.future);
tearDownAll(() => completer.complete(null));

group('$Firestore', () {
Firestore firestore;

setUp(() async {
final FirebaseApp app = await FirebaseApp.configure(
name: 'test',
options: const FirebaseOptions(
googleAppID: '1:79601577497:ios:5f2bcc6ba8cecddd',
gcmSenderID: '79601577497',
apiKey: 'AIzaSyArgmRGfB5kiQT6CunAOmKRVKEsxKmy6YI-G72PVU',
projectID: 'flutter-firestore',
),
);
firestore = Firestore(app: app);
});

test('getDocuments', () async {
final CollectionReference reference = firestore.collection('messages');
final QuerySnapshot snapshot = await reference.getDocuments();
expect(snapshot.documents.length, isNonZero);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void main() {
test('CloudFirestore driver test', () async {
final FlutterDriver driver = await FlutterDriver.connect();
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
}
[query getDocumentsWithCompletion:^(FIRQuerySnapshot *_Nullable snapshot,
NSError *_Nullable error) {
if (snapshot != nil) {
if (snapshot == nil) {
result(getFlutterError(error));
return;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/cloud_firestore/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Cloud Firestore, a cloud-hosted, noSQL database
live synchronization and offline support on Android and iOS.
author: Flutter Team <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_firestore
version: 0.9.6
version: 0.9.7

flutter:
plugin:
Expand All @@ -21,6 +21,9 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
test: any

environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
Expand Down

0 comments on commit 6aef375

Please sign in to comment.