Update key management for database service
This commit is contained in:
parent
1df21e88bd
commit
0118981e0a
8 changed files with 235 additions and 284 deletions
|
|
@ -4,7 +4,7 @@ import DataLiteC
|
|||
import DataLiteCore
|
||||
import DataRaft
|
||||
|
||||
class DatabaseServiceTests: DatabaseServiceKeyProvider {
|
||||
class DatabaseServiceTests: DatabaseServiceKeyProvider, @unchecked Sendable {
|
||||
private let keyOne = Connection.Key.rawKey(Data([
|
||||
0xe8, 0xd7, 0x92, 0xa2, 0xa1, 0x35, 0x56, 0xc0,
|
||||
0xfd, 0xbb, 0x2f, 0x91, 0xe8, 0x0b, 0x4b, 0x2a,
|
||||
|
|
@ -40,6 +40,7 @@ class DatabaseServiceTests: DatabaseServiceKeyProvider {
|
|||
self.service = service
|
||||
self.service.keyProvider = self
|
||||
|
||||
try self.service.applyKeyProvider()
|
||||
try self.service.perform { connection in
|
||||
try connection.execute(sql: """
|
||||
CREATE TABLE IF NOT EXISTS Item (
|
||||
|
|
@ -54,11 +55,11 @@ class DatabaseServiceTests: DatabaseServiceKeyProvider {
|
|||
try? FileManager.default.removeItem(at: fileURL)
|
||||
}
|
||||
|
||||
func databaseServiceKey(_ service: DatabaseService) throws -> Connection.Key? {
|
||||
func databaseService(keyFor service: any DatabaseServiceProtocol) throws -> Connection.Key? {
|
||||
currentKey
|
||||
}
|
||||
|
||||
func databaseServiceShouldReconnect(_ service: DatabaseService) -> Bool {
|
||||
func databaseService(shouldReconnect service: any DatabaseServiceProtocol) -> Bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import DataLiteCore
|
|||
init() throws {
|
||||
let connection = try Connection(location: .inMemory, options: .readwrite)
|
||||
self.connection = connection
|
||||
self.migrationService = .init(service: .init(connection: connection), storage: .init())
|
||||
self.migrationService = .init(service: try .init(connection: connection), storage: .init())
|
||||
}
|
||||
|
||||
@Test func addMigration() throws {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue