From 7baaee493db0a7041165199ca584995120bce8db Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Mon, 13 Feb 2017 22:17:03 +0900 Subject: [PATCH] unit test for scalar IDs for ImportableUniqueObject --- CoreStoreTests/ImportTests.swift | 23 +++---------------- .../Model.xcdatamodel/contents | 18 +++++++-------- README.md | 2 +- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/CoreStoreTests/ImportTests.swift b/CoreStoreTests/ImportTests.swift index 30ad492..38d48bd 100644 --- a/CoreStoreTests/ImportTests.swift +++ b/CoreStoreTests/ImportTests.swift @@ -1083,42 +1083,25 @@ extension TestEntity1: ImportableUniqueObject { // MARK: ImportableUniqueObject - typealias UniqueIDType = NSNumber + typealias UniqueIDType = Int64 static var uniqueIDKeyPath: String { return #keyPath(TestEntity1.testEntityID) } - var uniqueIDValue: NSNumber { - - get { - - guard let ID = self.testEntityID else { - - XCTFail() - return 0 - } - return ID - } - set { - - self.testEntityID = newValue - } - } - static func shouldUpdate(from source: ImportSource, in transaction: BaseDataTransaction) -> Bool { return source["skip_update"] == nil } - static func uniqueID(from source: ImportSource, in transaction: BaseDataTransaction) throws -> NSNumber? { + static func uniqueID(from source: ImportSource, in transaction: BaseDataTransaction) throws -> Int64? { if let _ = source["throw_on_id"] { throw TestIDError() } - return source[(#keyPath(TestEntity1.testEntityID))] as? NSNumber + return source[(#keyPath(TestEntity1.testEntityID))] as? Int64 } func update(from source: ImportSource, in transaction: BaseDataTransaction) throws { diff --git a/CoreStoreTests/Model.xcdatamodeld/Model.xcdatamodel/contents b/CoreStoreTests/Model.xcdatamodeld/Model.xcdatamodel/contents index d88951d..3aae67e 100644 --- a/CoreStoreTests/Model.xcdatamodeld/Model.xcdatamodel/contents +++ b/CoreStoreTests/Model.xcdatamodeld/Model.xcdatamodel/contents @@ -1,23 +1,23 @@ - + - + - + - + - + - + - + - + - + diff --git a/README.md b/README.md index df5d466..231c1f0 100644 --- a/README.md +++ b/README.md @@ -519,7 +519,7 @@ are created from `beginSynchronous(...)`. While the syntax is similar to its asy ```swift CoreStore.beginSynchronous { (transaction) -> Void in // make changes - transaction.commit() + _ = transaction.commit() } ``` `transaction` above is a `SynchronousDataTransaction` instance.