Skip to content

Commit

Permalink
Fix for error check
Browse files Browse the repository at this point in the history
  • Loading branch information
mentrena committed Aug 9, 2019
1 parent bd64d91 commit 516cfd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ class CloudKitSynchronizerTests: XCTestCase {
func testSynchronize_limitExceededErrorInPartialError_decreasesBatchSizeAndEndsWithError() {
let expectation = self.expectation(description: "sync finished")
let batchSize = synchronizer.batchSize
let innerError = NSError(domain: CKErrorDomain,
code: CKError.limitExceeded.rawValue,
userInfo: nil)
let error = NSError(domain: CKErrorDomain,
code: CKError.partialFailure.rawValue,
userInfo: [CKPartialErrorsByItemIDKey: ["itemId": NSError(domain: CKErrorDomain,
code: CKError.limitExceeded.rawValue,
userInfo: nil)]])
userInfo: [CKPartialErrorsByItemIDKey: [CKRecord.ID(recordName: "itemID", zoneID: recordZoneID): innerError]])
mockDatabase.uploadError = error
let object = QSObject(identifier: "1", number: 1)
mockAdapter.objects = [object]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extension CloudKitSynchronizer {
func isServerRecordChangedError(_ error: NSError) -> Bool {

if error.code == CKError.partialFailure.rawValue,
let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [String: NSError],
let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [CKRecord.ID: NSError],
errorsByItemID.values.contains(where: { (error) -> Bool in
return error.code == CKError.serverRecordChanged.rawValue
}) {
Expand All @@ -126,7 +126,7 @@ extension CloudKitSynchronizer {
func isLimitExceededError(_ error: NSError) -> Bool {

if error.code == CKError.partialFailure.rawValue,
let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [String: NSError],
let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [CKRecord.ID: NSError],
errorsByItemID.values.contains(where: { (error) -> Bool in
return error.code == CKError.limitExceeded.rawValue
}) {
Expand Down

0 comments on commit 516cfd9

Please sign in to comment.