Skip to content

Commit 339fff1

Browse files
Add Unit test
1 parent 5e1f03c commit 339fff1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,31 @@ public void testHandlesSetMutationThenDocument() {
239239
assertContains(doc("foo/bar", 2, map("foo", "bar"), true));
240240
}
241241

242+
@Test
243+
public void testHandlesSetMutationThenAckThenRelease() {
244+
Query query = Query.atPath(ResourcePath.fromSegments(asList("foo")));
245+
allocateQuery(query);
246+
247+
writeMutation(setMutation("foo/bar", map("foo", "bar")));
248+
assertChanged(doc("foo/bar", 0, map("foo", "bar"), true));
249+
assertContains(doc("foo/bar", 0, map("foo", "bar"), true));
250+
251+
acknowledgeMutation(1);
252+
notifyLocalViewChanges(viewChanges(2, asList("foo/bar"), emptyList()));
253+
254+
assertChanged();
255+
assertContains(doc("foo/bar", 0, map("foo", "bar"), true));
256+
257+
releaseQuery(query);
258+
259+
// It has been acknowledged, and should no longer be retained as there is no target and mutation
260+
if (garbageCollectorIsEager()) {
261+
assertNotContains("foo/bar");
262+
} else {
263+
assertContains(doc("foo/bar", 0, map("foo", "bar"), false));
264+
}
265+
}
266+
242267
@Test
243268
public void testHandlesAckThenRejectThenRemoteEvent() {
244269
// Start a query that requires acks to be held.

0 commit comments

Comments
 (0)