mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-16 22:16:53 +01:00
make some test cases validate specific error codes from thrown errors
This commit is contained in:
@@ -81,6 +81,33 @@ class BaseTestCase: XCTestCase {
|
||||
|
||||
CoreStore.logger = TestLogger(expectations)
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
func expectError<T>(code: CoreStoreErrorCode, closure: () throws -> T) {
|
||||
|
||||
CoreStore.logger = TestLogger(self.prepareLoggerExpectations([.logError]))
|
||||
defer {
|
||||
|
||||
self.checkExpectationsImmediately()
|
||||
CoreStore.logger = TestLogger([:])
|
||||
}
|
||||
do {
|
||||
|
||||
_ = try closure()
|
||||
}
|
||||
catch let error as CoreStoreError {
|
||||
|
||||
if error.errorCode == code.rawValue {
|
||||
|
||||
return
|
||||
}
|
||||
XCTFail("Expected error code \(code) different from actual error: \((error as NSError).coreStoreDumpString)")
|
||||
}
|
||||
catch {
|
||||
|
||||
XCTFail("Error not wrapped as \(cs_typeName(CoreStoreError.self)): \((error as NSError).coreStoreDumpString)")
|
||||
}
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
func prepareLoggerExpectations(_ expectations: [TestLogger.Expectation]) -> [TestLogger.Expectation: XCTestExpectation] {
|
||||
|
||||
@@ -376,17 +376,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K > %@", #keyPath(TestEntity1.testNumber), 1),
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -394,17 +391,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K < %@", #keyPath(TestEntity1.testNumber), 4),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -559,17 +553,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K > %@", #keyPath(TestEntity1.testNumber), 1),
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -577,17 +568,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K < %@", #keyPath(TestEntity1.testNumber), 4),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -881,17 +869,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K < %@", #keyPath(TestEntity1.testNumber), 4),
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -899,17 +884,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>(#keyPath(TestEntity1.testNumber), isEqualTo: 0),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -917,17 +899,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1119,34 +1098,28 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
let fetchClauses: [FetchClause] = [
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
do {
|
||||
|
||||
let fetchClauses: [FetchClause] = [
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1411,8 +1384,8 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
|
||||
let from = From<TestEntity1>("Config1")
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchCount(
|
||||
from,
|
||||
@@ -1420,11 +1393,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchCount(
|
||||
from,
|
||||
@@ -1432,11 +1404,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchCount(
|
||||
from,
|
||||
@@ -1444,7 +1415,6 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1561,8 +1531,8 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
|
||||
let from = From<TestEntity1>("Config2")
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchCount(
|
||||
from,
|
||||
@@ -1570,11 +1540,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchCount(
|
||||
from,
|
||||
@@ -1582,11 +1551,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try stack.fetchCount(
|
||||
from,
|
||||
@@ -1594,7 +1562,6 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1821,17 +1788,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K > %@", #keyPath(TestEntity1.testNumber), 1),
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -1839,17 +1803,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K < %@", #keyPath(TestEntity1.testNumber), 4),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
try transaction.cancel()
|
||||
}
|
||||
@@ -2015,17 +1976,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K > %@", #keyPath(TestEntity1.testNumber), 1),
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -2033,17 +1991,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K < %@", #keyPath(TestEntity1.testNumber), 4),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let object = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchOne(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(object as Any?)
|
||||
|
||||
let objectID = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectID(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectID as Any?)
|
||||
}
|
||||
try transaction.cancel()
|
||||
}
|
||||
@@ -2353,17 +2308,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>("%K < %@", #keyPath(TestEntity1.testNumber), 4),
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -2371,17 +2323,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>(#keyPath(TestEntity1.testNumber), isEqualTo: 0),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
do {
|
||||
|
||||
@@ -2389,17 +2338,14 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
Where<TestEntity1>(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
try transaction.cancel()
|
||||
}
|
||||
@@ -2614,34 +2560,28 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
let fetchClauses: [FetchClause] = [
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
do {
|
||||
|
||||
let fetchClauses: [FetchClause] = [
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
]
|
||||
let objects = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchAll(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objects)
|
||||
|
||||
let objectIDs = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchObjectIDs(from, fetchClauses)
|
||||
}
|
||||
XCTAssertNil(objectIDs)
|
||||
}
|
||||
try transaction.cancel()
|
||||
}
|
||||
@@ -2940,8 +2880,8 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
|
||||
let from = From<TestEntity1>("Config1")
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchCount(
|
||||
from,
|
||||
@@ -2949,11 +2889,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchCount(
|
||||
from,
|
||||
@@ -2961,11 +2900,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchCount(
|
||||
from,
|
||||
@@ -2973,7 +2911,6 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
try transaction.cancel()
|
||||
}
|
||||
@@ -3101,8 +3038,8 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
|
||||
let from = From<TestEntity1>("Config2")
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchCount(
|
||||
from,
|
||||
@@ -3110,11 +3047,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.ascending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchCount(
|
||||
from,
|
||||
@@ -3122,11 +3058,10 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
do {
|
||||
|
||||
let count = try? self.expectLogger([.logError]) {
|
||||
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try transaction.fetchCount(
|
||||
from,
|
||||
@@ -3134,7 +3069,6 @@ final class FetchTests: BaseTestDataTestCase {
|
||||
OrderBy<TestEntity1>(.descending(#keyPath(TestEntity1.testEntityID)))
|
||||
)
|
||||
}
|
||||
XCTAssertNil(count)
|
||||
}
|
||||
try transaction.cancel()
|
||||
}
|
||||
|
||||
@@ -89,11 +89,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity1>("Config1")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -145,11 +144,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity1>("Config2")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -163,11 +161,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity2>()
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -181,11 +178,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity2>("Config1")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -199,11 +195,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity2>("Config2")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -255,11 +250,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity1>("Config2")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -288,11 +282,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity2>("Config1")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -306,11 +299,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity2>("Config2")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -362,11 +354,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity1>("Config2")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
@@ -395,11 +386,10 @@ final class FromTests: BaseTestCase {
|
||||
let from = From<TestEntity2>("Config1")
|
||||
|
||||
let request = CoreStoreFetchRequest()
|
||||
let storesFound: Void? = try? self.expectLogger([.logError]) {
|
||||
self.expectError(code: .persistentStoreNotFound) {
|
||||
|
||||
try from.applyToFetchRequest(request, context: dataStack.mainContext)
|
||||
}
|
||||
XCTAssertNil(storesFound)
|
||||
XCTAssertNotNil(request.entity)
|
||||
XCTAssertNotNil(request.safeAffectedStores)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user