|
16 | 16 |
|
17 | 17 | #include "Firestore/core/test/unit/local/local_store_test.h" |
18 | 18 |
|
| 19 | +#include <unordered_map> |
19 | 20 | #include <utility> |
20 | 21 | #include <vector> |
21 | 22 |
|
|
31 | 32 | #include "Firestore/core/src/local/target_data.h" |
32 | 33 | #include "Firestore/core/src/model/delete_mutation.h" |
33 | 34 | #include "Firestore/core/src/model/document.h" |
| 35 | +#include "Firestore/core/src/model/document_key.h" |
34 | 36 | #include "Firestore/core/src/model/field_index.h" |
35 | 37 | #include "Firestore/core/src/model/mutable_document.h" |
| 38 | +#include "Firestore/core/src/model/mutation.h" |
36 | 39 | #include "Firestore/core/src/model/mutation_batch_result.h" |
37 | 40 | #include "Firestore/core/src/model/patch_mutation.h" |
38 | 41 | #include "Firestore/core/src/model/set_mutation.h" |
@@ -87,6 +90,7 @@ using testutil::DeletedDoc; |
87 | 90 | using testutil::Doc; |
88 | 91 | using testutil::Key; |
89 | 92 | using testutil::Map; |
| 93 | +using testutil::OverlayTypeMap; |
90 | 94 | using testutil::Query; |
91 | 95 | using testutil::UnknownDoc; |
92 | 96 | using testutil::UpdateRemoteEvent; |
@@ -906,6 +910,8 @@ TEST_P(LocalStoreTest, ReadsAllDocumentsForInitialCollectionQueries) { |
906 | 910 |
|
907 | 911 | FSTAssertRemoteDocumentsRead(/* by_key= */ 0, /* by_query= */ 2); |
908 | 912 | FSTAssertOverlaysRead(/* by_key= */ 0, /* by_query= */ 1); |
| 913 | + FSTAssertOverlayTypes( |
| 914 | + OverlayTypeMap({{Key("foo/bonk"), model::Mutation::Type::Set}})); |
909 | 915 | } |
910 | 916 |
|
911 | 917 | TEST_P(LocalStoreTest, PersistsResumeTokens) { |
@@ -1663,6 +1669,21 @@ TEST_P(LocalStoreTest, MultipleFieldPatchesOnLocalDocs) { |
1663 | 1669 | Doc("foo/bar", 0, Map("likes", 1, "stars", 2)).SetHasLocalMutations()); |
1664 | 1670 | } |
1665 | 1671 |
|
| 1672 | +TEST_P(LocalStoreTest, PatchMutationLeadsToPatchOverlay) { |
| 1673 | + AllocateQuery(Query("foo")); |
| 1674 | + ApplyRemoteEvent(UpdateRemoteEvent(Doc("foo/baz", 10, Map("a", 1)), {2}, {})); |
| 1675 | + ApplyRemoteEvent(UpdateRemoteEvent(Doc("foo/bar", 20, Map()), {2}, {})); |
| 1676 | + WriteMutation(testutil::PatchMutation("foo/baz", Map("b", 2))); |
| 1677 | + |
| 1678 | + ResetPersistenceStats(); |
| 1679 | + |
| 1680 | + ExecuteQuery(Query("foo")); |
| 1681 | + FSTAssertRemoteDocumentsRead(0, 2); |
| 1682 | + FSTAssertOverlaysRead(0, 1); |
| 1683 | + FSTAssertOverlayTypes( |
| 1684 | + OverlayTypeMap({{Key("foo/baz"), model::Mutation::Type::Patch}})); |
| 1685 | +} |
| 1686 | + |
1666 | 1687 | } // namespace local |
1667 | 1688 | } // namespace firestore |
1668 | 1689 | } // namespace firebase |
0 commit comments