|
899 | 899 | // Step 6: Fetch arrives (no-op, conflict already resolved) |
900 | 900 | await fetchedRecordZoneChangesCallback.notify() |
901 | 901 |
|
902 | | - await withKnownIssue("Server should win same-field conflict when it has a newer timestamp") { |
903 | | - try await userDatabase.read { db in |
904 | | - let post = try #require(try Post.find(1).fetchOne(db)) |
905 | | - #expect(post.title == "Hello from server") |
906 | | - } |
| 902 | + assertQuery( |
| 903 | + Post.find(1) |
| 904 | + .join(SyncMetadata.all) { $0.syncMetadataID.eq($1.id) } |
| 905 | + .select { |
| 906 | + SyncedRow<Post>.Columns( |
| 907 | + row: $0, |
| 908 | + userModificationTime: $1.userModificationTime |
| 909 | + ) |
| 910 | + }, |
| 911 | + database: userDatabase.database |
| 912 | + ) { |
| 913 | + """ |
| 914 | + ┌─────────────────────────────────┐ |
| 915 | + │ SyncedRow( │ |
| 916 | + │ row: Post( │ |
| 917 | + │ id: 1, │ |
| 918 | + │ title: "Hello from server", │ |
| 919 | + │ body: nil, │ |
| 920 | + │ isPublished: false │ |
| 921 | + │ ), │ |
| 922 | + │ userModificationTime: 60 │ |
| 923 | + │ ) │ |
| 924 | + └─────────────────────────────────┘ |
| 925 | + """ |
| 926 | + } |
| 927 | + assertInlineSnapshot(of: container.privateCloudDatabase, as: .customDump) { |
| 928 | + """ |
| 929 | + MockCloudDatabase( |
| 930 | + databaseScope: .private, |
| 931 | + storage: [ |
| 932 | + [0]: CKRecord( |
| 933 | + recordID: CKRecord.ID(1:posts/zone/__defaultOwner__), |
| 934 | + recordType: "posts", |
| 935 | + parent: nil, |
| 936 | + share: nil, |
| 937 | + body🗓️: 0, |
| 938 | + id: 1, |
| 939 | + id🗓️: 0, |
| 940 | + isPublished: 0, |
| 941 | + isPublished🗓️: 0, |
| 942 | + title: "Hello from server", |
| 943 | + title🗓️: 60, |
| 944 | + 🗓️: 60 |
| 945 | + ) |
| 946 | + ] |
| 947 | + ) |
| 948 | + """ |
907 | 949 | } |
908 | 950 | } |
909 | 951 |
|
|
1119 | 1161 | // Step 6: Retry send |
1120 | 1162 | try await syncEngine.processPendingRecordZoneChanges(scope: .private) |
1121 | 1163 |
|
1122 | | - await withKnownIssue("Server should win same-field conflict when it has a newer timestamp") { |
1123 | | - try await userDatabase.read { db in |
1124 | | - let post = try #require(try Post.find(1).fetchOne(db)) |
1125 | | - #expect(post.title == "Hello from server") |
1126 | | - } |
| 1164 | + assertQuery( |
| 1165 | + Post.find(1) |
| 1166 | + .join(SyncMetadata.all) { $0.syncMetadataID.eq($1.id) } |
| 1167 | + .select { |
| 1168 | + SyncedRow<Post>.Columns( |
| 1169 | + row: $0, |
| 1170 | + userModificationTime: $1.userModificationTime |
| 1171 | + ) |
| 1172 | + }, |
| 1173 | + database: userDatabase.database |
| 1174 | + ) { |
| 1175 | + """ |
| 1176 | + ┌─────────────────────────────────┐ |
| 1177 | + │ SyncedRow( │ |
| 1178 | + │ row: Post( │ |
| 1179 | + │ id: 1, │ |
| 1180 | + │ title: "Hello from server", │ |
| 1181 | + │ body: nil, │ |
| 1182 | + │ isPublished: false │ |
| 1183 | + │ ), │ |
| 1184 | + │ userModificationTime: 60 │ |
| 1185 | + │ ) │ |
| 1186 | + └─────────────────────────────────┘ |
| 1187 | + """ |
| 1188 | + } |
| 1189 | + assertInlineSnapshot(of: container.privateCloudDatabase, as: .customDump) { |
| 1190 | + """ |
| 1191 | + MockCloudDatabase( |
| 1192 | + databaseScope: .private, |
| 1193 | + storage: [ |
| 1194 | + [0]: CKRecord( |
| 1195 | + recordID: CKRecord.ID(1:posts/zone/__defaultOwner__), |
| 1196 | + recordType: "posts", |
| 1197 | + parent: nil, |
| 1198 | + share: nil, |
| 1199 | + body🗓️: 0, |
| 1200 | + id: 1, |
| 1201 | + id🗓️: 0, |
| 1202 | + isPublished: 0, |
| 1203 | + isPublished🗓️: 0, |
| 1204 | + title: "Hello from server", |
| 1205 | + title🗓️: 60, |
| 1206 | + 🗓️: 60 |
| 1207 | + ) |
| 1208 | + ] |
| 1209 | + ) |
| 1210 | + """ |
1127 | 1211 | } |
1128 | 1212 | } |
1129 | 1213 |
|
|
1416 | 1500 | // Step 5: Send (merged result) |
1417 | 1501 | try await syncEngine.processPendingRecordZoneChanges(scope: .private) |
1418 | 1502 |
|
1419 | | - await withKnownIssue("Server should win same-field conflict when it has a newer timestamp") { |
1420 | | - try await userDatabase.read { db in |
1421 | | - let post = try #require(try Post.find(1).fetchOne(db)) |
1422 | | - #expect(post.title == "Hello from server") |
1423 | | - } |
| 1503 | + assertQuery( |
| 1504 | + Post.find(1) |
| 1505 | + .join(SyncMetadata.all) { $0.syncMetadataID.eq($1.id) } |
| 1506 | + .select { |
| 1507 | + SyncedRow<Post>.Columns( |
| 1508 | + row: $0, |
| 1509 | + userModificationTime: $1.userModificationTime |
| 1510 | + ) |
| 1511 | + }, |
| 1512 | + database: userDatabase.database |
| 1513 | + ) { |
| 1514 | + """ |
| 1515 | + ┌─────────────────────────────────┐ |
| 1516 | + │ SyncedRow( │ |
| 1517 | + │ row: Post( │ |
| 1518 | + │ id: 1, │ |
| 1519 | + │ title: "Hello from server", │ |
| 1520 | + │ body: nil, │ |
| 1521 | + │ isPublished: false │ |
| 1522 | + │ ), │ |
| 1523 | + │ userModificationTime: 60 │ |
| 1524 | + │ ) │ |
| 1525 | + └─────────────────────────────────┘ |
| 1526 | + """ |
| 1527 | + } |
| 1528 | + assertInlineSnapshot(of: container.privateCloudDatabase, as: .customDump) { |
| 1529 | + """ |
| 1530 | + MockCloudDatabase( |
| 1531 | + databaseScope: .private, |
| 1532 | + storage: [ |
| 1533 | + [0]: CKRecord( |
| 1534 | + recordID: CKRecord.ID(1:posts/zone/__defaultOwner__), |
| 1535 | + recordType: "posts", |
| 1536 | + parent: nil, |
| 1537 | + share: nil, |
| 1538 | + body🗓️: 0, |
| 1539 | + id: 1, |
| 1540 | + id🗓️: 0, |
| 1541 | + isPublished: 0, |
| 1542 | + isPublished🗓️: 0, |
| 1543 | + title: "Hello from server", |
| 1544 | + title🗓️: 60, |
| 1545 | + 🗓️: 60 |
| 1546 | + ) |
| 1547 | + ] |
| 1548 | + ) |
| 1549 | + """ |
1424 | 1550 | } |
1425 | 1551 | } |
1426 | 1552 |
|
|
1642 | 1768 | // Step 6: Fetch arrives (no-op, conflict already resolved) |
1643 | 1769 | await fetchedRecordZoneChangesCallback.notify() |
1644 | 1770 |
|
1645 | | - await withKnownIssue("Server should win same-field conflict when it has a newer timestamp") { |
1646 | | - try await userDatabase.read { db in |
1647 | | - let post = try #require(try Post.find(1).fetchOne(db)) |
1648 | | - #expect(post.body == "Server body") |
1649 | | - } |
| 1771 | + assertQuery( |
| 1772 | + Post.find(1) |
| 1773 | + .join(SyncMetadata.all) { $0.syncMetadataID.eq($1.id) } |
| 1774 | + .select { |
| 1775 | + SyncedRow<Post>.Columns( |
| 1776 | + row: $0, |
| 1777 | + userModificationTime: $1.userModificationTime |
| 1778 | + ) |
| 1779 | + }, |
| 1780 | + database: userDatabase.database |
| 1781 | + ) { |
| 1782 | + """ |
| 1783 | + ┌────────────────────────────┐ |
| 1784 | + │ SyncedRow( │ |
| 1785 | + │ row: Post( │ |
| 1786 | + │ id: 1, │ |
| 1787 | + │ title: "Hello", │ |
| 1788 | + │ body: "Server body", │ |
| 1789 | + │ isPublished: false │ |
| 1790 | + │ ), │ |
| 1791 | + │ userModificationTime: 60 │ |
| 1792 | + │ ) │ |
| 1793 | + └────────────────────────────┘ |
| 1794 | + """ |
| 1795 | + } |
| 1796 | + assertInlineSnapshot(of: container.privateCloudDatabase, as: .customDump) { |
| 1797 | + """ |
| 1798 | + MockCloudDatabase( |
| 1799 | + databaseScope: .private, |
| 1800 | + storage: [ |
| 1801 | + [0]: CKRecord( |
| 1802 | + recordID: CKRecord.ID(1:posts/zone/__defaultOwner__), |
| 1803 | + recordType: "posts", |
| 1804 | + parent: nil, |
| 1805 | + share: nil, |
| 1806 | + body: "Server body", |
| 1807 | + body🗓️: 60, |
| 1808 | + id: 1, |
| 1809 | + id🗓️: 0, |
| 1810 | + isPublished: 0, |
| 1811 | + isPublished🗓️: 0, |
| 1812 | + title: "Hello", |
| 1813 | + title🗓️: 0, |
| 1814 | + 🗓️: 60 |
| 1815 | + ) |
| 1816 | + ] |
| 1817 | + ) |
| 1818 | + """ |
1650 | 1819 | } |
1651 | 1820 | } |
1652 | 1821 |
|
|
0 commit comments