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

Merge branch 'feature/unimplemented' into 'development'

Replace failing constructors with unimplemented constructors

See merge request elixxir/client-ios-db!32
parents 15e03592 f99331c7
No related branches found
No related tags found
2 merge requests!32Replace failing constructors with unimplemented constructors,!30Release v1.2.0
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : { "state" : {
"revision" : "50a70a9d3583fe228ce672e8923010c8df2deddd", "revision" : "30314f1ece684dd60679d598a9b89107557b67d9",
"version" : "0.2.1" "version" : "0.4.1"
} }
} }
], ],
......
...@@ -14,77 +14,47 @@ let package = Package( ...@@ -14,77 +14,47 @@ let package = Package(
.macOS(.v12), .macOS(.v12),
], ],
products: [ products: [
.library( .library(name: "XXModels", targets: ["XXModels"]),
name: "XXModels", .library(name: "XXLegacyDatabaseMigrator", targets: ["XXLegacyDatabaseMigrator"]),
targets: ["XXModels"] .library(name: "XXDatabase", targets: ["XXDatabase"]),
),
.library(
name: "XXLegacyDatabaseMigrator",
targets: ["XXLegacyDatabaseMigrator"]
),
.library(
name: "XXDatabase",
targets: ["XXDatabase"]
),
], ],
dependencies: [ dependencies: [
.package( .package(url: "https://github.com/groue/GRDB.swift", .upToNextMajor(from: "5.24.0")),
url: "https://github.com/groue/GRDB.swift", .package(url: "https://github.com/pointfreeco/swift-custom-dump.git", .upToNextMajor(from: "0.4.0")),
.upToNextMajor(from: "5.24.0") .package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", .upToNextMajor(from: "1.9.0")),
), .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay.git", .upToNextMajor(from: "0.4.1")),
.package(
url: "https://github.com/pointfreeco/swift-custom-dump.git",
.upToNextMajor(from: "0.4.0")
),
.package(
url: "https://github.com/pointfreeco/swift-snapshot-testing.git",
.upToNextMajor(from: "1.9.0")
),
], ],
targets: [ targets: [
.target( .target(
name: "XXModels", name: "XXModels",
dependencies: [
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
],
swiftSettings: swiftSettings swiftSettings: swiftSettings
), ),
.testTarget( .testTarget(
name: "XXModelsTests", name: "XXModelsTests",
dependencies: [ dependencies: [
.target( .target(name: "XXModels"),
name: "XXModels"
),
], ],
swiftSettings: swiftSettings swiftSettings: swiftSettings
), ),
.target( .target(
name: "XXLegacyDatabaseMigrator", name: "XXLegacyDatabaseMigrator",
dependencies: [ dependencies: [
.target( .target(name: "XXDatabase"),
name: "XXDatabase" .target(name: "XXModels"),
), .product(name: "GRDB", package: "GRDB.swift"),
.target( .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
name: "XXModels"
),
.product(
name: "GRDB",
package: "GRDB.swift"
),
], ],
swiftSettings: swiftSettings swiftSettings: swiftSettings
), ),
.testTarget( .testTarget(
name: "XXLegacyDatabaseMigratorTests", name: "XXLegacyDatabaseMigratorTests",
dependencies: [ dependencies: [
.target( .target(name: "XXLegacyDatabaseMigrator"),
name: "XXLegacyDatabaseMigrator" .product(name: "CustomDump", package: "swift-custom-dump"),
), .product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
.product(
name: "CustomDump",
package: "swift-custom-dump"
),
.product(
name: "SnapshotTesting",
package: "swift-snapshot-testing"
),
], ],
exclude: [ exclude: [
"__Snapshots__", "__Snapshots__",
...@@ -100,26 +70,16 @@ let package = Package( ...@@ -100,26 +70,16 @@ let package = Package(
.target( .target(
name: "XXDatabase", name: "XXDatabase",
dependencies: [ dependencies: [
.target( .target(name: "XXModels"),
name: "XXModels" .product(name: "GRDB", package: "GRDB.swift"),
),
.product(
name: "GRDB",
package: "GRDB.swift"
),
], ],
swiftSettings: swiftSettings swiftSettings: swiftSettings
), ),
.testTarget( .testTarget(
name: "XXDatabaseTests", name: "XXDatabaseTests",
dependencies: [ dependencies: [
.target( .target(name: "XXDatabase"),
name: "XXDatabase" .product(name: "CustomDump", package: "swift-custom-dump"),
),
.product(
name: "CustomDump",
package: "swift-custom-dump"
),
], ],
swiftSettings: swiftSettings swiftSettings: swiftSettings
), ),
......
...@@ -70,7 +70,11 @@ extension Migrator { ...@@ -70,7 +70,11 @@ extension Migrator {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension Migrator { extension Migrator {
public static let failing = Migrator { _, _, _, _ in fatalError() } public static let unimplemented = Migrator(
run: XCTUnimplemented("\(Self.self)")
)
} }
#endif #endif
...@@ -177,37 +177,37 @@ public struct Database { ...@@ -177,37 +177,37 @@ public struct Database {
#if DEBUG #if DEBUG
extension Database { extension Database {
static public let failing = Database( static public let unimplemented = Database(
fetchChatInfos: .failing(), fetchChatInfos: .unimplemented(),
fetchChatInfosPublisher: .failing(), fetchChatInfosPublisher: .unimplemented(),
fetchContacts: .failing(), fetchContacts: .unimplemented(),
fetchContactsPublisher: .failing(), fetchContactsPublisher: .unimplemented(),
saveContact: .failing(), saveContact: .unimplemented(),
bulkUpdateContacts: .failing(), bulkUpdateContacts: .unimplemented(),
deleteContact: .failing(), deleteContact: .unimplemented(),
fetchContactChatInfos: .failing(), fetchContactChatInfos: .unimplemented(),
fetchContactChatInfosPublisher: .failing(), fetchContactChatInfosPublisher: .unimplemented(),
fetchGroups: .failing(), fetchGroups: .unimplemented(),
fetchGroupsPublisher: .failing(), fetchGroupsPublisher: .unimplemented(),
saveGroup: .failing(), saveGroup: .unimplemented(),
deleteGroup: .failing(), deleteGroup: .unimplemented(),
fetchGroupChatInfos: .failing(), fetchGroupChatInfos: .unimplemented(),
fetchGroupChatInfosPublisher: .failing(), fetchGroupChatInfosPublisher: .unimplemented(),
fetchGroupInfos: .failing(), fetchGroupInfos: .unimplemented(),
fetchGroupInfosPublisher: .failing(), fetchGroupInfosPublisher: .unimplemented(),
saveGroupMember: .failing(), saveGroupMember: .unimplemented(),
deleteGroupMember: .failing(), deleteGroupMember: .unimplemented(),
fetchMessages: .failing(), fetchMessages: .unimplemented(),
fetchMessagesPublisher: .failing(), fetchMessagesPublisher: .unimplemented(),
saveMessage: .failing(), saveMessage: .unimplemented(),
bulkUpdateMessages: .failing(), bulkUpdateMessages: .unimplemented(),
deleteMessage: .failing(), deleteMessage: .unimplemented(),
deleteMessages: .failing(), deleteMessages: .unimplemented(),
fetchFileTransfers: .failing(), fetchFileTransfers: .unimplemented(),
fetchFileTransfersPublisher: .failing(), fetchFileTransfersPublisher: .unimplemented(),
saveFileTransfer: .failing(), saveFileTransfer: .unimplemented(),
deleteFileTransfer: .failing(), deleteFileTransfer: .unimplemented(),
drop: .failing drop: .unimplemented
) )
} }
#endif #endif
...@@ -22,9 +22,11 @@ public struct BulkUpdate<Query, Assignments> { ...@@ -22,9 +22,11 @@ public struct BulkUpdate<Query, Assignments> {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension BulkUpdate { extension BulkUpdate {
public static func failing<Query, Assignments>() -> BulkUpdate<Query, Assignments> { public static func unimplemented<Query, Assignments>() -> BulkUpdate<Query, Assignments> {
BulkUpdate<Query, Assignments> { _, _ in fatalError() } BulkUpdate<Query, Assignments>(run: XCTUnimplemented("\(Self.self)"))
} }
} }
#endif #endif
...@@ -22,9 +22,11 @@ public struct Delete<Model> { ...@@ -22,9 +22,11 @@ public struct Delete<Model> {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension Delete { extension Delete {
public static func failing<Model>() -> Delete<Model> { public static func unimplemented<Model>() -> Delete<Model> {
Delete<Model> { _ in fatalError() } Delete<Model>(run: XCTUnimplemented("\(Self.self)"))
} }
} }
#endif #endif
...@@ -21,9 +21,11 @@ public struct DeleteMany<Model, Query> { ...@@ -21,9 +21,11 @@ public struct DeleteMany<Model, Query> {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension DeleteMany { extension DeleteMany {
public static func failing<Model, Query>() -> DeleteMany<Model, Query> { public static func unimplemented<Model>() -> DeleteMany<Model, Query> {
DeleteMany<Model, Query> { _ in fatalError() } DeleteMany<Model, Query>(run: XCTUnimplemented("\(Self.self)"))
} }
} }
#endif #endif
...@@ -20,7 +20,9 @@ public struct Drop { ...@@ -20,7 +20,9 @@ public struct Drop {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension Drop { extension Drop {
public static let failing = Drop { fatalError() } public static let unimplemented = Drop(run: XCTUnimplemented("\(Self.self)"))
} }
#endif #endif
...@@ -22,9 +22,11 @@ public struct Fetch<Model, Query> { ...@@ -22,9 +22,11 @@ public struct Fetch<Model, Query> {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension Fetch { extension Fetch {
public static func failing<Model, Query>() -> Fetch<Model, Query> { public static func unimplemented<Model, Query>() -> Fetch<Model, Query> {
Fetch<Model, Query> { _ in fatalError() } Fetch<Model, Query>(run: XCTUnimplemented("\(Self.self)"))
} }
} }
#endif #endif
...@@ -23,9 +23,13 @@ public struct FetchPublisher<Model, Query> { ...@@ -23,9 +23,13 @@ public struct FetchPublisher<Model, Query> {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension FetchPublisher { extension FetchPublisher {
public static func failing<Model, Query>() -> FetchPublisher<Model, Query> { public static func unimplemented<Model, Query>() -> FetchPublisher<Model, Query> {
FetchPublisher<Model, Query> { _ in fatalError() } FetchPublisher<Model, Query>(
run: XCTUnimplemented("\(Self.self)", placeholder: Empty().eraseToAnyPublisher())
)
} }
} }
#endif #endif
...@@ -25,9 +25,11 @@ public struct Save<Model> { ...@@ -25,9 +25,11 @@ public struct Save<Model> {
} }
#if DEBUG #if DEBUG
import XCTestDynamicOverlay
extension Save { extension Save {
public static func failing<Model>() -> Save<Model> { public static func unimplemented<Model>() -> Save<Model> {
Save<Model> { _ in fatalError() } Save<Model>(run: XCTUnimplemented("\(Self.self)"))
} }
} }
#endif #endif
...@@ -36,7 +36,7 @@ final class MigratorTests: XCTestCase { ...@@ -36,7 +36,7 @@ final class MigratorTests: XCTestCase {
var didSaveContacts = [XXModels.Contact]() var didSaveContacts = [XXModels.Contact]()
var newDb = XXModels.Database.failing var newDb = XXModels.Database.unimplemented
newDb.fetchContacts = .init { _ in [] } newDb.fetchContacts = .init { _ in [] }
newDb.saveContact = .init(run: { newDb.saveContact = .init(run: {
didSaveContacts.append($0) didSaveContacts.append($0)
...@@ -182,7 +182,7 @@ final class MigratorTests: XCTestCase { ...@@ -182,7 +182,7 @@ final class MigratorTests: XCTestCase {
// Mock up new database: // Mock up new database:
var newDb = XXModels.Database.failing var newDb = XXModels.Database.unimplemented
newDb.fetchContacts = .init { _ in [] } newDb.fetchContacts = .init { _ in [] }
newDb.saveContact = .init { $0 } 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