|
125 | 125 | let record = CKRecord( |
126 | 126 | recordType: "Record", |
127 | 127 | recordID: CKRecord.ID( |
128 | | - recordName: "Record", zoneID: CKRecordZone.ID(zoneName: "unknownZone")) |
| 128 | + recordName: "Record", |
| 129 | + zoneID: CKRecordZone.ID(zoneName: "unknownZone") |
| 130 | + ) |
129 | 131 | ) |
130 | 132 |
|
131 | 133 | let (saveRecordResults, _) = try syncEngine.private.database.modifyRecords( |
|
389 | 391 | @Test func saveShareWithoutRootRecord() async throws { |
390 | 392 | let record = CKRecord(recordType: "A", recordID: CKRecord.ID(recordName: "1")) |
391 | 393 | let share = CKShare(rootRecord: record, shareID: CKRecord.ID(recordName: "share")) |
392 | | - try withKnownIssue { |
393 | | - _ = try syncEngine.modifyRecords(scope: .private, saving: [share]) |
394 | | - } matching: { issue in |
395 | | - issue.description.hasSuffix( |
396 | | - """ |
397 | | - An added share is being saved without its rootRecord being saved in the \ |
398 | | - same operation. |
399 | | - """) |
| 394 | + let (saveResults, _) = try syncEngine.private.database.modifyRecords(saving: [share]) |
| 395 | + let error = #expect(throws: CKError.self) { |
| 396 | + try saveResults.values.first?.get() |
400 | 397 | } |
| 398 | + #expect(error?.code == .invalidArguments) |
401 | 399 | } |
402 | 400 |
|
403 | 401 | @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) |
404 | 402 | @Test func saveShareAndRootThenSaveShareAlone() async throws { |
405 | 403 | let record = CKRecord(recordType: "A", recordID: CKRecord.ID(recordName: "1")) |
406 | 404 | let share = CKShare(rootRecord: record, shareID: CKRecord.ID(recordName: "share")) |
407 | | - _ = try syncEngine.modifyRecords(scope: .private, saving: [share, record]) |
| 405 | + _ = try syncEngine.private.database.modifyRecords(saving: [share, record]) |
408 | 406 |
|
409 | 407 | let newShare = try syncEngine.private.database.record(for: CKRecord.ID(recordName: "share")) |
410 | | - _ = try syncEngine.modifyRecords(scope: .private, saving: [newShare]) |
| 408 | + let (saveResults, _) = try syncEngine.private.database.modifyRecords(saving: [newShare]) |
| 409 | + _ = try saveResults.values.first?.get() |
| 410 | + } |
| 411 | + |
| 412 | + @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) |
| 413 | + @Test func saveRecordThatWasPreviouslyDeleted() async throws { |
| 414 | + let record = CKRecord(recordType: "A", recordID: CKRecord.ID(recordName: "1")) |
| 415 | + _ = try syncEngine.private.database.modifyRecords(saving: [record]) |
| 416 | + let freshRecord = try syncEngine.private.database.record(for: record.recordID) |
| 417 | + _ = try syncEngine.private.database.modifyRecords(deleting: [record.recordID]) |
| 418 | + let (saveResults, _) = try syncEngine.private.database.modifyRecords(saving: [freshRecord]) |
| 419 | + let error = #expect(throws: CKError.self) { |
| 420 | + try saveResults.values.first?.get() |
| 421 | + } |
| 422 | + #expect(error?.code == .unknownItem) |
411 | 423 | } |
412 | 424 | } |
413 | 425 | } |
|
0 commit comments