Skip to content

Commit db42b45

Browse files
committed
Copy records in notify() to prevent MockCloudDatabase mutation
1 parent d95d7cd commit db42b45

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Tests/SQLiteDataTests/Internal/CloudKitTestHelpers.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ extension SyncEngine {
9393
return ModifyRecordsCallback {
9494
await syncEngine.parentSyncEngine.handleEvent(
9595
.fetchedRecordZoneChanges(
96-
modifications: saveResults.values.compactMap { try? $0.get() },
96+
modifications: saveResults.values.compactMap {
97+
guard let record = try? $0.get() else { return nil }
98+
return record.copy() as? CKRecord
99+
},
97100
deletions: deleteResults.compactMap { recordID, result in
98101
(recordsToDeleteByID[recordID]?.recordType).flatMap { recordType in
99102
(try? result.get()) != nil

0 commit comments

Comments
 (0)