-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Delete stale Firestore instances after FIRApp is deleted. #809
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d3b77b1
Delete stale Firestore instances after FIRApp is deleted.
ryanwilson 4e84ae8
What year is it?
ryanwilson 5e2a31f
Address comments, fix prefix issue
ryanwilson 73b2872
Reduce timeout to reasonable amount.
ryanwilson ffb595d
Verify instances are still returned properly.
ryanwilson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2018 Google | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <FirebaseCore/FIRAppInternal.h> | ||
#import <FirebaseCore/FIROptionsInternal.h> | ||
#import <FirebaseFirestore/FIRFirestore.h> | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
@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]; | ||
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app]; | ||
XCTAssertEqualObjects(firestore.app, app); | ||
|
||
// Ensure that firestoreForApp returns the same instance. | ||
XCTAssertEqualObjects(firestore, [FIRFirestore firestoreForApp:app]); | ||
|
||
XCTestExpectation *defaultAppDeletedExpectation = | ||
[self expectationWithDescription: | ||
@"Deleting the default app should invalidate the default " | ||
@"Firestore instance."]; | ||
[app deleteApp:^(BOOL success) { | ||
// Recreate the FIRApp with the same name, fetch a new Firestore instance and make sure it's | ||
// different than the other one. | ||
[FIRApp configureWithName:appName options:options]; | ||
FIRApp *newApp = [FIRApp appNamed:appName]; | ||
FIRFirestore *newInstance = [FIRFirestore firestoreForApp:newApp]; | ||
XCTAssertNotEqualObjects(newInstance, firestore); | ||
|
||
[defaultAppDeletedExpectation fulfill]; | ||
}]; | ||
|
||
[self waitForExpectations:@[ defaultAppDeletedExpectation ] timeout:2]; | ||
} | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a check that verifies
[FIRFirestore firestoreForApp:app]
returns the same instance above.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what you mean - do you mean call
[FIRFirestore firestoreForApp:]
twice and ensure the same instance is returned?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's what I mean (at line ~40). It makes it possible to know that the
XCTAssertNotEqualObjects(newInstance, firestore)
is meaningful here becauseXCTAssertEqualObjects(newInstance, firestore)
was true absent this work.