mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 10:21:40 +01:00
make unit tests happy
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
language: objective-c
|
language: objective-c
|
||||||
osx_image: xcode8.3.2
|
osx_image: xcode8.3
|
||||||
sudo: false
|
sudo: false
|
||||||
git:
|
git:
|
||||||
submodules: false
|
submodules: false
|
||||||
|
|||||||
@@ -28,12 +28,18 @@ import XCTest
|
|||||||
@testable
|
@testable
|
||||||
import CoreStore
|
import CoreStore
|
||||||
|
|
||||||
|
#if os(OSX)
|
||||||
|
typealias Color = NSColor
|
||||||
|
#else
|
||||||
|
|
||||||
|
typealias Color = UIColor
|
||||||
|
#endif
|
||||||
|
|
||||||
class Animal: CoreStoreObject {
|
class Animal: CoreStoreObject {
|
||||||
|
|
||||||
let species = Value.Required<String>("species", default: "Swift")
|
let species = Value.Required<String>("species", default: "Swift")
|
||||||
let master = Relationship.ToOne<Person>("master")
|
let master = Relationship.ToOne<Person>("master")
|
||||||
let color = Transformable.Optional<UIColor>("color")
|
let color = Transformable.Optional<Color>("color")
|
||||||
}
|
}
|
||||||
|
|
||||||
class Dog: Animal {
|
class Dog: Animal {
|
||||||
@@ -102,7 +108,7 @@ class DynamicModelTests: BaseTestDataTestCase {
|
|||||||
XCTAssertEqual(animal.species.value, "Sparrow")
|
XCTAssertEqual(animal.species.value, "Sparrow")
|
||||||
|
|
||||||
animal.color .= .yellow
|
animal.color .= .yellow
|
||||||
XCTAssertEqual(animal.color.value, UIColor.yellow)
|
XCTAssertEqual(animal.color.value, Color.yellow)
|
||||||
|
|
||||||
let dog = transaction.create(Into<Dog>())
|
let dog = transaction.create(Into<Dog>())
|
||||||
XCTAssertEqual(dog.species.value, "Swift")
|
XCTAssertEqual(dog.species.value, "Swift")
|
||||||
@@ -168,7 +174,6 @@ class DynamicModelTests: BaseTestDataTestCase {
|
|||||||
success: {
|
success: {
|
||||||
|
|
||||||
fetchDone.fulfill()
|
fetchDone.fulfill()
|
||||||
withExtendedLifetime(stack, {})
|
|
||||||
},
|
},
|
||||||
failure: { _ in
|
failure: { _ in
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
|||||||
|
|
||||||
self.bridgeToSwift.context.saveAsynchronouslyWithCompletion { (_, error) in
|
self.bridgeToSwift.context.saveAsynchronouslyWithCompletion { (_, error) in
|
||||||
|
|
||||||
|
defer {
|
||||||
|
|
||||||
|
withExtendedLifetime(self, {})
|
||||||
|
}
|
||||||
if let error = error {
|
if let error = error {
|
||||||
|
|
||||||
failure?(error.bridgeToObjectiveC)
|
failure?(error.bridgeToObjectiveC)
|
||||||
@@ -55,7 +59,6 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
|||||||
|
|
||||||
success?()
|
success?()
|
||||||
}
|
}
|
||||||
withExtendedLifetime(self, {})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +220,10 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
|||||||
|
|
||||||
self.bridgeToSwift.context.saveAsynchronouslyWithCompletion { (hasChanges, error) in
|
self.bridgeToSwift.context.saveAsynchronouslyWithCompletion { (hasChanges, error) in
|
||||||
|
|
||||||
|
defer {
|
||||||
|
|
||||||
|
withExtendedLifetime(self, {})
|
||||||
|
}
|
||||||
if let error = error {
|
if let error = error {
|
||||||
|
|
||||||
completion?(SaveResult(error).bridgeToObjectiveC)
|
completion?(SaveResult(error).bridgeToObjectiveC)
|
||||||
@@ -225,7 +232,6 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
|||||||
|
|
||||||
completion?(SaveResult(hasChanges: hasChanges).bridgeToObjectiveC)
|
completion?(SaveResult(hasChanges: hasChanges).bridgeToObjectiveC)
|
||||||
}
|
}
|
||||||
withExtendedLifetime(self, {})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public extension DataStack {
|
|||||||
|
|
||||||
defer {
|
defer {
|
||||||
|
|
||||||
withExtendedLifetime(transaction, {})
|
withExtendedLifetime((self, transaction), {})
|
||||||
}
|
}
|
||||||
let userInfo: T
|
let userInfo: T
|
||||||
do {
|
do {
|
||||||
@@ -112,7 +112,7 @@ public extension DataStack {
|
|||||||
|
|
||||||
defer {
|
defer {
|
||||||
|
|
||||||
withExtendedLifetime(transaction, {})
|
withExtendedLifetime((self, transaction), {})
|
||||||
}
|
}
|
||||||
let userInfo: T
|
let userInfo: T
|
||||||
do {
|
do {
|
||||||
|
|||||||
Reference in New Issue
Block a user