-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
attempt to reproduce #8286 #8618
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
*/ | ||
|
||
#import "FirebaseDatabase/Tests/Integration/FIRDatabaseQueryTests.h" | ||
#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h" | ||
//#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h" doesn't work with swift? | ||
#import "FirebaseDatabase/Sources/Api/Private/FIRDatabaseQuery_Private.h" | ||
#import "FirebaseDatabase/Sources/Constants/FConstants.h" | ||
#import "FirebaseDatabase/Sources/Core/FQuerySpec.h" | ||
|
@@ -4468,4 +4468,67 @@ - (void)testGetSkipsPersistenceCacheWhenOnline { | |
WAIT_FOR(done); | ||
} | ||
|
||
- (void)testGetTriggersListener { | ||
FIRDatabase* db = [self databaseForURL:self.databaseURL name:@"fir-multi-shards"]; | ||
|
||
FIRDatabaseReference* ref = [db referenceWithPath:@"james"]; | ||
FIRDatabaseReference* children = [ref child:@"children"]; | ||
|
||
__block BOOL done = NO; | ||
|
||
[children removeValueWithCompletionBlock:^(NSError* _Nullable error, | ||
FIRDatabaseReference* _Nonnull ref) { | ||
XCTAssertNil(error); | ||
done = YES; | ||
}]; | ||
|
||
WAIT_FOR(done); | ||
done = NO; | ||
|
||
[[children childByAutoId] setValue:@{@"name" : @1} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One difference between this test and the issue is that the test does not write values from the same instance, but rather all values exist on the backend. We can emulate this using a reader/writer test setup. |
||
withCompletionBlock:^(NSError* error, FIRDatabaseReference* ref) { | ||
XCTAssertNil(error); | ||
done = YES; | ||
}]; | ||
|
||
WAIT_FOR(done); | ||
done = NO; | ||
|
||
[[children childByAutoId] setValue:@{@"name" : @2} | ||
withCompletionBlock:^(NSError* error, FIRDatabaseReference* ref) { | ||
XCTAssertNil(error); | ||
done = YES; | ||
}]; | ||
|
||
WAIT_FOR(done); | ||
done = NO; | ||
|
||
__block BOOL nextDone = NO; | ||
|
||
[children observeEventType:FIRDataEventTypeValue | ||
withBlock:^(FIRDataSnapshot* snapshot) { | ||
if (done == YES) { | ||
XCTAssertTrue(snapshot.childrenCount == 2U); | ||
nextDone = YES; | ||
return; | ||
} | ||
XCTAssertTrue(snapshot.childrenCount == 2U); | ||
done = YES; | ||
}]; | ||
|
||
WAIT_FOR(done); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original repo also does not wait for "done". It runs both operation in parallel. |
||
|
||
__block BOOL getDone = NO; | ||
|
||
[[[children queryOrderedByChild:@"name"] queryEqualToValue:@2] | ||
getDataWithCompletionBlock:^(NSError* _Nullable error, FIRDataSnapshot* _Nonnull snapshot) { | ||
XCTAssertNil(error); | ||
XCTAssertTrue([snapshot exists]); | ||
getDone = YES; | ||
}]; | ||
|
||
WAIT_FOR(getDone); | ||
// WAIT_FOR(nextDone); // when uncommented, test times out. | ||
} | ||
|
||
@end |
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.
You could use an
autoId
instead ofchildren
(via[FTestHelpers getRandomNode]
). Then you won't have to do a delete.