Skip to content

Commit e8659b5

Browse files
authored
DocumentOverlayCacheTestCase.testUpdateDocumentOverlay() added (#3463)
* DocumentOverlayCacheTestCase.java.testUpdateDocumentOverlay() added, ported from firebase/firebase-ios-sdk@cf04e67 * empty commit to re-run presubmits
1 parent 62d868a commit e8659b5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

firebase-firestore/src/test/java/com/google/firebase/firestore/local/DocumentOverlayCacheTestCase.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ public void testGetAllOverlaysFromCollectionGroupWithLimitIncludesFullBatches()
236236
verifyOverlayContains(overlays, "coll/doc1", "coll/doc2", "coll/doc3");
237237
}
238238

239+
@Test
240+
public void testUpdateDocumentOverlay() {
241+
Mutation mutation1 = setMutation("coll/doc", map("foo", 1));
242+
Mutation mutation2 = setMutation("coll/doc", map("foo", 2));
243+
saveOverlays(1, mutation1);
244+
saveOverlays(2, mutation2);
245+
246+
// Verify that `getOverlay()` returns the updated mutation.
247+
Overlay overlay = cache.getOverlay(DocumentKey.fromPathString("coll/doc"));
248+
assertEquals(overlay, Overlay.create(2, mutation2));
249+
250+
// Verify that `removeOverlaysForBatchId()` removes the overlay completely.
251+
cache.removeOverlaysForBatchId(2);
252+
assertNull(cache.getOverlay(DocumentKey.fromPathString("coll/doc")));
253+
}
254+
239255
void verifyOverlayContains(Map<DocumentKey, Overlay> overlays, String... keys) {
240256
Set<DocumentKey> expected = Arrays.stream(keys).map(TestUtil::key).collect(Collectors.toSet());
241257
assertThat(overlays.keySet()).containsExactlyElementsIn(expected);

0 commit comments

Comments
 (0)