mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Make sure empty migrator publisher is async as well
This commit is contained in:
1 parent
914ad1b882
commit
fcff9b34ba
1 file changed
+28
-1
@@ -207,7 +207,34 @@ class DatabaseMigratorTests : GRDBTestCase {
|
||||
.runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
|
||||
}
|
||||
|
||||
func testMigratorPublisherIsAsynchronous() throws {
|
||||
func testEmptyMigratorPublisherIsAsynchronous() throws {
|
||||
guard #available(OSX 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
|
||||
throw XCTSkip("Combine is not available")
|
||||
}
|
||||
|
||||
func test(writer: DatabaseWriter) throws {
|
||||
let migrator = DatabaseMigrator()
|
||||
let expectation = self.expectation(description: "")
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
let cancellable = migrator.migratePublisher(writer).sink(
|
||||
receiveCompletion: { _ in },
|
||||
receiveValue: { _ in
|
||||
semaphore.wait()
|
||||
expectation.fulfill()
|
||||
})
|
||||
|
||||
semaphore.signal()
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
cancellable.cancel()
|
||||
}
|
||||
|
||||
try Test(test)
|
||||
.run { DatabaseQueue() }
|
||||
.runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
|
||||
.runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
|
||||
}
|
||||
|
||||
func testNonEmptyMigratorPublisherIsAsynchronous() throws {
|
||||
guard #available(OSX 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
|
||||
throw XCTSkip("Combine is not available")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user