Skip to content

Commit b50d854

Browse files
Fix integration test
1 parent 3a4b71d commit b50d854

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ - (void)testCanUpdateAnUnknownDocument {
6565
[self readDocumentForRef:writerRef source:FIRFirestoreSourceCache];
6666
XCTAssertTrue(writerSnap.exists);
6767

68-
XCTAssertThrows(^() {
69-
[self readDocumentForRef:readerRef source:FIRFirestoreSourceCache];
70-
});
68+
XCTestExpectation *expectation =
69+
[self expectationWithDescription:@"testCanUpdateAnUnknownDocument"];
70+
[readerRef getDocumentWithSource:FIRFirestoreSourceCache
71+
completion:^(FIRDocumentSnapshot *doc, NSError *_Nullable error) {
72+
XCTAssertNotNil(error);
73+
[expectation fulfill];
74+
}];
75+
[self awaitExpectations];
7176

7277
writerSnap = [self readDocumentForRef:writerRef];
7378
XCTAssertEqualObjects(writerSnap.data, (@{@"a" : @"a", @"b" : @"b"}));

Firestore/Source/Core/FSTFirestoreClient.mm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,20 @@ - (void)getDocumentFromLocalCache:(FIRDocumentReference *)doc
287287
FSTMaybeDocument *maybeDoc = [self.localStore readDocument:doc.key];
288288
FIRDocumentSnapshot *_Nullable result = nil;
289289
NSError *_Nullable error = nil;
290-
if (maybeDoc) {
291-
FSTDocument *_Nullable document =
292-
([maybeDoc isKindOfClass:[FSTDocument class]]) ? (FSTDocument *)maybeDoc : nil;
290+
291+
if ([maybeDoc isKindOfClass:[FSTDocument class]]) {
292+
FSTDocument *document = (FSTDocument *)maybeDoc;
293293
result = [FIRDocumentSnapshot snapshotWithFirestore:doc.firestore
294294
documentKey:doc.key
295295
document:document
296296
fromCache:YES
297297
hasPendingWrites:document.hasLocalMutations];
298+
} else if ([maybeDoc isKindOfClass:[FSTDeletedDocument class]]) {
299+
result = [FIRDocumentSnapshot snapshotWithFirestore:doc.firestore
300+
documentKey:doc.key
301+
document:nil
302+
fromCache:YES
303+
hasPendingWrites:NO];
298304
} else {
299305
error = [NSError errorWithDomain:FIRFirestoreErrorDomain
300306
code:FIRFirestoreErrorCodeUnavailable

Firestore/Source/Local/FSTLocalStore.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ - (void)releaseQuery:(FSTQuery *)query {
407407
queryData = cachedQueryData;
408408
[self.queryCache updateQueryData:queryData];
409409
}
410-
410+
411411
// References for documents sent via Watch are automatically removed when we delete a
412412
// query's target data from the reference delegate. Since this does not remove references
413413
// for locally mutated documents, we have to remove the target associations for these

0 commit comments

Comments
 (0)