diff --git a/Examples/xx-messenger/Sources/AppFeature/AppEnvironment+Live.swift b/Examples/xx-messenger/Sources/AppFeature/AppEnvironment+Live.swift index 49ea8087585a70a1cbd61827b08b15de43682d1b..9b298c38ac898334659b1fa5b5f463ce2012ce3e 100644 --- a/Examples/xx-messenger/Sources/AppFeature/AppEnvironment+Live.swift +++ b/Examples/xx-messenger/Sources/AppFeature/AppEnvironment+Live.swift @@ -36,7 +36,7 @@ extension AppEnvironment { home: { HomeEnvironment( messenger: messenger, - db: dbManager.getDB, + dbManager: dbManager, mainQueue: mainQueue, bgQueue: bgQueue, register: { diff --git a/Examples/xx-messenger/Sources/HomeFeature/HomeFeature.swift b/Examples/xx-messenger/Sources/HomeFeature/HomeFeature.swift index 51083ea0ccea39c7bf13abdd0ff0566dac623529..712855ba1ba4aecfe467679b4fcc87090de4ee43 100644 --- a/Examples/xx-messenger/Sources/HomeFeature/HomeFeature.swift +++ b/Examples/xx-messenger/Sources/HomeFeature/HomeFeature.swift @@ -71,14 +71,14 @@ public enum HomeAction: Equatable { public struct HomeEnvironment { public init( messenger: Messenger, - db: DBManagerGetDB, + dbManager: DBManager, mainQueue: AnySchedulerOf<DispatchQueue>, bgQueue: AnySchedulerOf<DispatchQueue>, register: @escaping () -> RegisterEnvironment, userSearch: @escaping () -> UserSearchEnvironment ) { self.messenger = messenger - self.db = db + self.dbManager = dbManager self.mainQueue = mainQueue self.bgQueue = bgQueue self.register = register @@ -86,7 +86,7 @@ public struct HomeEnvironment { } public var messenger: Messenger - public var db: DBManagerGetDB + public var dbManager: DBManager public var mainQueue: AnySchedulerOf<DispatchQueue> public var bgQueue: AnySchedulerOf<DispatchQueue> public var register: () -> RegisterEnvironment @@ -96,7 +96,7 @@ public struct HomeEnvironment { extension HomeEnvironment { public static let unimplemented = HomeEnvironment( messenger: .unimplemented, - db: .unimplemented, + dbManager: .unimplemented, mainQueue: .unimplemented, bgQueue: .unimplemented, register: { .unimplemented }, @@ -197,13 +197,13 @@ public let homeReducer = Reducer<HomeState, HomeAction, HomeEnvironment> return .result { do { let contactId = try env.messenger.e2e.tryGet().getContact().getId() - let contact = try env.db().fetchContacts(.init(id: [contactId])).first + let contact = try env.dbManager.getDB().fetchContacts(.init(id: [contactId])).first if let username = contact?.username { let ud = try env.messenger.ud.tryGet() try ud.permanentDeleteAccount(username: Fact(fact: username, type: 0)) } try env.messenger.destroy() - try env.db().drop() + try env.dbManager.removeDB() return .success(.deleteAccount(.success)) } catch { return .success(.deleteAccount(.failure(error as NSError))) diff --git a/Examples/xx-messenger/Tests/HomeFeatureTests/HomeFeatureTests.swift b/Examples/xx-messenger/Tests/HomeFeatureTests/HomeFeatureTests.swift index aa309016c08c4a75e62c6ecd5cf47e32191832e1..cbc261cefd8f85153c3316d08bada0337cceea35 100644 --- a/Examples/xx-messenger/Tests/HomeFeatureTests/HomeFeatureTests.swift +++ b/Examples/xx-messenger/Tests/HomeFeatureTests/HomeFeatureTests.swift @@ -316,7 +316,7 @@ final class HomeFeatureTests: XCTestCase { var dbDidFetchContacts: [XXModels.Contact.Query] = [] var udDidPermanentDeleteAccount: [Fact] = [] var messengerDidDestroy = 0 - var dbDidDrop = 0 + var didRemoveDB = 0 store.environment.bgQueue = .immediate store.environment.mainQueue = .immediate @@ -329,7 +329,7 @@ final class HomeFeatureTests: XCTestCase { } return e2e } - store.environment.db.run = { + store.environment.dbManager.getDB.run = { var db: Database = .failing db.fetchContacts.run = { query in dbDidFetchContacts.append(query) @@ -341,11 +341,11 @@ final class HomeFeatureTests: XCTestCase { ) ] } - db.drop.run = { - dbDidDrop += 1 - } return db } + store.environment.dbManager.removeDB.run = { + didRemoveDB += 1 + } store.environment.messenger.ud.get = { var ud: UserDiscovery = .unimplemented ud.permanentDeleteAccount.run = { usernameFact in @@ -372,7 +372,7 @@ final class HomeFeatureTests: XCTestCase { XCTAssertNoDifference(dbDidFetchContacts, [.init(id: ["contact-id".data(using: .utf8)!])]) XCTAssertNoDifference(udDidPermanentDeleteAccount, [Fact(fact: "MyUsername", type: 0)]) XCTAssertNoDifference(messengerDidDestroy, 1) - XCTAssertNoDifference(dbDidDrop, 1) + XCTAssertNoDifference(didRemoveDB, 1) store.receive(.deleteAccount(.success)) { $0.isDeletingAccount = false