Repository navigation
Overhaul of merge conflict tests - #414
Draft
lukaskubanek wants to merge 26 commits into
Draft
lukaskubanek wants to merge 26 commits into
lukaskubanek wants to merge 26 commits into
Conversation
lukaskubanek
added a commit
to structuredpath/sqlite-data
that referenced
this pull request
Mar 26, 2026
Introduce Post table type Add differentFieldsChange_conflictOnSend_clientNewer test Add differentFieldsChange_conflictOnSend_serverNewer test Remove replaced tests Add differentFieldsChange_conflictOnFetch_clientNewer test Add differentFieldsChange_conflictOnFetch_serverNewer test Add convergence assertions for local state Remove replaced test Add sameFieldChange_conflictOnSend_retryBeforeFetch_* tests Add sameFieldChange_conflictOnSend_fetchBeforeRetry_* tests Add sameFieldChange_conflictOnFetch_clientNewer test Add sameFieldChange_conflictOnFetch_serverNewer test Remove replaced tests Add sameFieldChangeAndRemoval_* tests Update test for updating nullable fields Combine local database assertions into a single join query Add sameFieldChange_conflictOnSend_equalTimestamps test Add sameFieldRemoval_conflictOnSend_clientNewer test Add sameFieldRemoval_conflictOnSend_serverNewer test Improve synced row query asserts
This was referenced Jul 28, 2026
`CKRecord.copyWithMockSystemFields(…)` returns a copy with the given values stored in the real system fields, so they behave like server-assigned values without swizzling. Supports `modificationDate` only for now and is not yet used by `MockCloudDatabase`.
Records saved in a batch now receive an incrementing modification date, mirroring the CloudKit server. The sync engine's modification date checks therefore run in tests as they do in production, which changes an expectation in one merge conflict test.
`MockCloudDatabase` now stores the change tag in the real system field as well, while the sync machinery still reads `_recordChangeTag` for now.
`MockCloudDatabase` and `MockSyncEngine` now read `CKRecord.recordChangeTag` from the record's system field instead of the `_recordChangeTag` mock field, which is removed along with its `isTesting` persistence branches. Change tags become strings but remain digit-based for now, to be replaced later.
Matches the format CloudKit uses for `CKRecord.recordChangeTag`.
lukaskubanek
force-pushed
the
merge-conflict-tests
branch
from
November 4, 2026 14:17
42a5682 to
e7271a1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
This PR depends on #507, #508 and #510, which are merged, and on #573, which is still open. It is stacked on #573 and includes its commits. The isolated diff is available here. The branch will be rebased once #573 is merged.
Summary
This PR replaces the existing merge conflict tests in
MergeConflictTests.swiftwith a new test suite that covers a broader set of scenarios across multiple dimensions:The new tests expose two real bugs in the current merge conflict resolution logic. These are temporarily marked with
withKnownIssue, as the main goal of this PR is to document the current behavior and form a baseline for future work on configurable conflict resolution.Improvements
Posttable type (standalone, no parent entity required) instead ofReminder, which depends onRemindersList.container.privateCloudDatabasedirectly, reducing boilerplate compared to the full container, as the shared database isn’t interesting for these tests.t=30,t=60) for client modification instead of relative increments. This is now aligned with howCKRecords are being treated.Bugs Identified
The new tests reveal the following issues in the current implementation:
Overview
differentFieldsChange_conflictOnSend_clientNewerisPublished@ t=60title@ t=30serverRecordUpdatedBeforeClientRecorddifferentFieldsChange_conflictOnSend_serverNewerisPublished@ t=30title@ t=60clientRecordUpdatedBeforeServerRecorddifferentFieldsChange_conflictOnFetch_clientNewerisPublished@ t=60title@ t=30serverAndClientEditDifferentFieldsdifferentFieldsChange_conflictOnFetch_serverNewerisPublished@ t=30title@ t=60differentNullableFieldsChange_conflictOnFetch_clientNewerpriority@ t=60dueDate@ t=30mergeWithNullableFieldssameFieldChange_conflictOnSend_retryBeforeFetch_clientNewertitle@ t=60title@ t=30sameFieldChange_conflictOnSend_retryBeforeFetch_serverNewertitle@ t=30title@ t=60sameFieldChange_conflictOnSend_fetchBeforeRetry_clientNewertitle@ t=60title@ t=30serverRecordEditedBeforeClientButProcessedAfterClientsameFieldChange_conflictOnSend_fetchBeforeRetry_serverNewertitle@ t=30title@ t=60sameFieldChange_conflictOnSend_equalValues_clientNewertitle@ t=60title@ t=30title@ t=60title@ t=30sameFieldChange_conflictOnSend_equalValues_serverNewertitle@ t=30title@ t=60title@ t=60title@ t=60sameFieldChange_conflictOnSend_equalTimestampstitle@ t=60title@ t=60sameFieldChange_conflictOnFetch_clientNewertitle@ t=60title@ t=30serverRecordEditedAndProcessedBeforeClientsameFieldChange_conflictOnFetch_serverNewertitle@ t=30title@ t=60serverRecordEditedAfterClientButProcessedBeforeClientsameFieldChangeAndRemoval_conflictOnSend_clientNewerbody@ t=60body@ t=30sameFieldChangeAndRemoval_conflictOnSend_serverNewerbody@ t=30body@ t=60sameFieldRemoval_conflictOnSend_clientNewerbody@ t=60body@ t=30body@ t=60body@ t=30sameFieldRemoval_conflictOnSend_serverNewerbody@ t=30body@ t=60body@ t=60body@ t=60Next Steps