diff options
author | Gil <mcg@google.com> | 2018-02-22 08:26:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-22 08:26:22 -0800 |
commit | 4dc63f8d7cbf60417b88c6a77839ea32656627b9 (patch) | |
tree | 9e06e7c40b71caea3a89813a506c9aebccdf1401 /Firestore/Example/Tests | |
parent | 935f3ca7d749f96c7207236a39c57f32a02c05d3 (diff) |
Fix Firestore tests for M22 (#834)
* Add FIRFirestoreTests to the Firestore Xcode project
* Avoid waitForExpectations:timeout:
This API was added in Xcode 8.3, but we still build production releases
with Xcode 8.2. waitForExpectationsWithTimeout:handler: is available
from Xcode 7.2.
* Add AppForUnitTesting
Add a utility for constructing a Firebase App for testing.
* Handle the nil UID from FIRAuth
* Avoid running CMake tests twice
* Only build app_testing on Apple platforms
* Revise test.sh messages
Diffstat (limited to 'Firestore/Example/Tests')
-rw-r--r-- | Firestore/Example/Tests/API/FIRFirestoreTests.mm | 21 | ||||
-rw-r--r-- | Firestore/Example/Tests/SpecTests/FSTSpecTests.mm | 8 |
2 files changed, 15 insertions, 14 deletions
diff --git a/Firestore/Example/Tests/API/FIRFirestoreTests.mm b/Firestore/Example/Tests/API/FIRFirestoreTests.mm index 4daf35a..7cb49b7 100644 --- a/Firestore/Example/Tests/API/FIRFirestoreTests.mm +++ b/Firestore/Example/Tests/API/FIRFirestoreTests.mm @@ -20,21 +20,21 @@ #import <XCTest/XCTest.h> +#include "Firestore/core/test/firebase/firestore/testutil/app_testing.h" + +namespace testutil = firebase::firestore::testutil; + @interface FIRFirestoreTests : XCTestCase @end @implementation FIRFirestoreTests - (void)testDeleteApp { - // Create a FIRApp for testing. - NSString *appName = @"custom_app_name"; - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:@"1:123:ios:123ab" GCMSenderID:@"gcm_sender_id"]; - options.projectID = @"project_id"; - [FIRApp configureWithName:appName options:options]; - // Ensure the app is set appropriately. - FIRApp *app = [FIRApp appNamed:appName]; + FIRApp *app = testutil::AppForUnitTesting(); + NSString *appName = app.name; + FIROptions *options = app.options; + FIRFirestore *firestore = [FIRFirestore firestoreForApp:app]; XCTAssertEqualObjects(firestore.app, app); @@ -56,7 +56,10 @@ [defaultAppDeletedExpectation fulfill]; }]; - [self waitForExpectations:@[ defaultAppDeletedExpectation ] timeout:2]; + [self waitForExpectationsWithTimeout:2 + handler:^(NSError *_Nullable error) { + XCTAssertNil(error); + }]; } @end diff --git a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm index 87e3213..43b2a5f 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm +++ b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm @@ -332,12 +332,10 @@ static NSString *const kNoIOSTag = @"no-ios"; } - (void)doChangeUser:(id)UID { - if (UID == nil || [UID isEqual:[NSNull null]]) { - [self.driver changeUser:User::Unauthenticated()]; - } else { - XCTAssert([UID isKindOfClass:[NSString class]]); - [self.driver changeUser:User(UID)]; + if ([UID isEqual:[NSNull null]]) { + UID = nil; } + [self.driver changeUser:User::FromUid(UID)]; } - (void)doRestart { |