Skip to content
Snippets Groups Projects
Commit 8ccac1c0 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add unimplemented constructors

parent e6c6ea08
Branches
Tags
2 merge requests!32Replace failing constructors with unimplemented constructors,!30Release v1.2.0
......@@ -70,7 +70,13 @@ extension Migrator {
}
#if DEBUG
import XCTestDynamicOverlay
extension Migrator {
public static let failing = Migrator { _, _, _, _ in fatalError() }
public static let unimplemented = Migrator(
run: XCTUnimplemented("\(Self.self)")
)
}
#endif
......@@ -209,5 +209,38 @@ extension Database {
deleteFileTransfer: .failing(),
drop: .failing
)
static public let unimplemented = Database(
fetchChatInfos: .unimplemented(),
fetchChatInfosPublisher: .unimplemented(),
fetchContacts: .unimplemented(),
fetchContactsPublisher: .unimplemented(),
saveContact: .unimplemented(),
bulkUpdateContacts: .unimplemented(),
deleteContact: .unimplemented(),
fetchContactChatInfos: .unimplemented(),
fetchContactChatInfosPublisher: .unimplemented(),
fetchGroups: .unimplemented(),
fetchGroupsPublisher: .unimplemented(),
saveGroup: .unimplemented(),
deleteGroup: .unimplemented(),
fetchGroupChatInfos: .unimplemented(),
fetchGroupChatInfosPublisher: .unimplemented(),
fetchGroupInfos: .unimplemented(),
fetchGroupInfosPublisher: .unimplemented(),
saveGroupMember: .unimplemented(),
deleteGroupMember: .unimplemented(),
fetchMessages: .unimplemented(),
fetchMessagesPublisher: .unimplemented(),
saveMessage: .unimplemented(),
bulkUpdateMessages: .unimplemented(),
deleteMessage: .unimplemented(),
deleteMessages: .unimplemented(),
fetchFileTransfers: .unimplemented(),
fetchFileTransfersPublisher: .unimplemented(),
saveFileTransfer: .unimplemented(),
deleteFileTransfer: .unimplemented(),
drop: .unimplemented
)
}
#endif
......@@ -22,9 +22,15 @@ public struct BulkUpdate<Query, Assignments> {
}
#if DEBUG
import XCTestDynamicOverlay
extension BulkUpdate {
public static func failing<Query, Assignments>() -> BulkUpdate<Query, Assignments> {
BulkUpdate<Query, Assignments> { _, _ in fatalError() }
}
public static func unimplemented<Query, Assignments>() -> BulkUpdate<Query, Assignments> {
BulkUpdate<Query, Assignments>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -22,9 +22,15 @@ public struct Delete<Model> {
}
#if DEBUG
import XCTestDynamicOverlay
extension Delete {
public static func failing<Model>() -> Delete<Model> {
Delete<Model> { _ in fatalError() }
}
public static func unimplemented<Model>() -> Delete<Model> {
Delete<Model>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -21,9 +21,15 @@ public struct DeleteMany<Model, Query> {
}
#if DEBUG
import XCTestDynamicOverlay
extension DeleteMany {
public static func failing<Model, Query>() -> DeleteMany<Model, Query> {
DeleteMany<Model, Query> { _ in fatalError() }
}
public static func unimplemented<Model>() -> DeleteMany<Model, Query> {
DeleteMany<Model, Query>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -20,7 +20,10 @@ public struct Drop {
}
#if DEBUG
import XCTestDynamicOverlay
extension Drop {
public static let failing = Drop { fatalError() }
public static let unimplemented = Drop(run: XCTUnimplemented("\(Self.self)"))
}
#endif
......@@ -22,9 +22,15 @@ public struct Fetch<Model, Query> {
}
#if DEBUG
import XCTestDynamicOverlay
extension Fetch {
public static func failing<Model, Query>() -> Fetch<Model, Query> {
Fetch<Model, Query> { _ in fatalError() }
}
public static func unimplemented<Model, Query>() -> Fetch<Model, Query> {
Fetch<Model, Query>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -23,9 +23,17 @@ public struct FetchPublisher<Model, Query> {
}
#if DEBUG
import XCTestDynamicOverlay
extension FetchPublisher {
public static func failing<Model, Query>() -> FetchPublisher<Model, Query> {
FetchPublisher<Model, Query> { _ in fatalError() }
}
public static func unimplemented<Model, Query>() -> FetchPublisher<Model, Query> {
FetchPublisher<Model, Query>(
run: XCTUnimplemented("\(Self.self)", placeholder: Empty().eraseToAnyPublisher())
)
}
}
#endif
......@@ -25,9 +25,15 @@ public struct Save<Model> {
}
#if DEBUG
import XCTestDynamicOverlay
extension Save {
public static func failing<Model>() -> Save<Model> {
Save<Model> { _ in fatalError() }
}
public static func unimplemented<Model>() -> Save<Model> {
Save<Model>(run: XCTUnimplemented("\(Self.self)"))
}
}
#endif
......@@ -36,7 +36,7 @@ final class MigratorTests: XCTestCase {
var didSaveContacts = [XXModels.Contact]()
var newDb = XXModels.Database.failing
var newDb = XXModels.Database.unimplemented
newDb.fetchContacts = .init { _ in [] }
newDb.saveContact = .init(run: {
didSaveContacts.append($0)
......@@ -182,7 +182,7 @@ final class MigratorTests: XCTestCase {
// Mock up new database:
var newDb = XXModels.Database.failing
var newDb = XXModels.Database.unimplemented
newDb.fetchContacts = .init { _ in [] }
newDb.saveContact = .init { $0 }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment