mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
waitForExpectations must be isolated to MainActor
This commit is contained in:
1 parent
5fc36a0a1b
commit
eebf8b1c20
9 files changed
+48
No files matched your search
@@ -966,6 +966,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testTargetQueue() throws {
|
||||
func test(targetQueue: DispatchQueue) throws {
|
||||
dbConfiguration.targetQueue = targetQueue
|
||||
@@ -990,6 +991,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {
|
||||
waitForExpectations(timeout: 2, handler: nil)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testWriteTargetQueue() throws {
|
||||
func test(targetQueue: DispatchQueue, writeTargetQueue: DispatchQueue) throws {
|
||||
dbConfiguration.targetQueue = targetQueue
|
||||
@@ -1214,6 +1216,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {
|
||||
XCTAssertEqual(count, 0)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAsyncConcurrentReadError() throws {
|
||||
// Necessary for this test to run as quickly as possible
|
||||
dbConfiguration.readonlyBusyMode = .immediateError
|
||||
@@ -1241,6 +1244,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Barrier
|
||||
|
||||
@MainActor
|
||||
func testBarrierLocksReads() throws {
|
||||
let expectation = self.expectation(description: "lock")
|
||||
expectation.isInverted = true
|
||||
@@ -1284,6 +1288,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {
|
||||
XCTAssertEqual(fetchedValue, 1)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testBarrierIsLockedByOneUnfinishedRead() throws {
|
||||
let expectation = self.expectation(description: "lock")
|
||||
expectation.isInverted = true
|
||||
|
||||
@@ -151,6 +151,7 @@ class DatabaseQueueTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testTargetQueue() throws {
|
||||
func test(targetQueue: DispatchQueue) throws {
|
||||
dbConfiguration.targetQueue = targetQueue
|
||||
@@ -175,6 +176,7 @@ class DatabaseQueueTests: GRDBTestCase {
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testWriteTargetQueue() throws {
|
||||
func test(targetQueue: DispatchQueue, writeTargetQueue: DispatchQueue) throws {
|
||||
dbConfiguration.targetQueue = targetQueue // unused
|
||||
|
||||
@@ -204,6 +204,7 @@ class DatabaseReaderTests : GRDBTestCase {
|
||||
|
||||
// MARK: - AsyncRead
|
||||
|
||||
@MainActor
|
||||
func testAsyncRead() throws {
|
||||
func test(_ dbReader: some DatabaseReader) throws {
|
||||
let expectation = self.expectation(description: "updates")
|
||||
@@ -235,6 +236,7 @@ class DatabaseReaderTests : GRDBTestCase {
|
||||
#endif
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAsyncReadPreventsDatabaseModification() throws {
|
||||
func test(_ dbReader: some DatabaseReader) throws {
|
||||
let expectation = self.expectation(description: "updates")
|
||||
|
||||
@@ -42,6 +42,7 @@ class DatabaseRegionObservationTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testDatabaseRegionObservation_ImmediateCancellation() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write {
|
||||
|
||||
@@ -39,6 +39,7 @@ class DatabaseWriterTests : GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAsyncWriteWithoutTransactionSuccess() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
let expectation = self.expectation(description: "updates")
|
||||
@@ -64,6 +65,7 @@ class DatabaseWriterTests : GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAsyncWriteWithoutTransactionError() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
let expectation = self.expectation(description: "updates")
|
||||
@@ -89,6 +91,7 @@ class DatabaseWriterTests : GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAsyncWriteSuccess() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
let expectation = self.expectation(description: "updates")
|
||||
@@ -118,6 +121,7 @@ class DatabaseWriterTests : GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAsyncWriteError() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
let expectation = self.expectation(description: "updates")
|
||||
|
||||
@@ -91,6 +91,7 @@ class PoolTests: XCTestCase {
|
||||
fourth.release(.reuse)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testBarrierLocksElements() throws {
|
||||
let expectation = self.expectation(description: "lock")
|
||||
expectation.isInverted = true
|
||||
@@ -130,6 +131,7 @@ class PoolTests: XCTestCase {
|
||||
XCTAssertEqual(element, 1)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testBarrierIsLockedByOneUsedElementOutOfOne() throws {
|
||||
let expectation = self.expectation(description: "lock")
|
||||
expectation.isInverted = true
|
||||
@@ -162,6 +164,7 @@ class PoolTests: XCTestCase {
|
||||
second.release(.reuse)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testBarrierIsLockedByOneUsedElementOutOfTwo() throws {
|
||||
let expectation = self.expectation(description: "lock")
|
||||
expectation.isInverted = true
|
||||
@@ -199,6 +202,7 @@ class PoolTests: XCTestCase {
|
||||
third.release(.reuse)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testBarrierIsLockedByTwoUsedElementsOutOfTwo() throws {
|
||||
let expectation = self.expectation(description: "lock")
|
||||
expectation.isInverted = true
|
||||
@@ -234,6 +238,7 @@ class PoolTests: XCTestCase {
|
||||
third.release(.reuse)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testBarrierRemoveAll() throws {
|
||||
let expectation = self.expectation(description: "lock")
|
||||
expectation.isInverted = true
|
||||
|
||||
@@ -22,6 +22,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Readonly
|
||||
|
||||
@MainActor
|
||||
func test_readonly_success_asynchronousScheduling() throws {
|
||||
let dbPool = try makeDatabasePool(filename: "test")
|
||||
try dbPool.write { db in
|
||||
@@ -59,6 +60,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
#endif
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_readonly_success_immediateScheduling() throws {
|
||||
let dbPool = try makeDatabasePool(filename: "test")
|
||||
try dbPool.write { db in
|
||||
@@ -96,6 +98,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
#endif
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_readonly_failure_asynchronousScheduling() throws {
|
||||
struct TestError: Error { }
|
||||
let dbPool = try makeDatabasePool(filename: "test")
|
||||
@@ -134,6 +137,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
#endif
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_readonly_failure_immediateScheduling() throws {
|
||||
struct TestError: Error { }
|
||||
let dbPool = try makeDatabasePool(filename: "test")
|
||||
@@ -174,6 +178,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Writeonly
|
||||
|
||||
@MainActor
|
||||
func test_writeonly_success_asynchronousScheduling() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
try dbWriter.write { db in
|
||||
@@ -216,6 +221,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_writeonly_success_immediateScheduling() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
try dbWriter.write { db in
|
||||
@@ -258,6 +264,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_writeonly_immediateFailure_asynchronousScheduling() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
let logger = TestStream()
|
||||
@@ -285,6 +292,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_writeonly_immediateFailure_immediateScheduling() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
let logger = TestStream()
|
||||
@@ -312,6 +320,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_writeonly_lateFailure_asynchronousScheduling() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
try dbWriter.write { db in
|
||||
@@ -355,6 +364,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_writeonly_lateFailure_immediateScheduling() throws {
|
||||
func test(_ dbWriter: some DatabaseWriter) throws {
|
||||
try dbWriter.write { db in
|
||||
@@ -400,6 +410,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Concurrent
|
||||
|
||||
@MainActor
|
||||
func test_concurrent_success_asynchronousScheduling() throws {
|
||||
let dbPool = try makeDatabasePool()
|
||||
try dbPool.write { db in
|
||||
@@ -453,6 +464,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_concurrent_success_immediateScheduling() throws {
|
||||
let dbPool = try makeDatabasePool()
|
||||
try dbPool.write { db in
|
||||
@@ -504,6 +516,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Varying Database Region
|
||||
|
||||
@MainActor
|
||||
func test_varyingRegion() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write { db in
|
||||
@@ -560,6 +573,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Variations
|
||||
|
||||
@MainActor
|
||||
func test_prefix() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write { db in
|
||||
@@ -594,6 +608,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_chain() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write { db in
|
||||
@@ -630,6 +645,7 @@ class ValueObservationPrintTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func test_handleEvents() throws {
|
||||
func waitFor<R: ValueReducer>(_ observation: ValueObservation<R>) throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
|
||||
@@ -119,6 +119,7 @@ class ValueObservationRegionRecordingTests: GRDBTestCase {
|
||||
onChange: { (int: Int, string: String) in }) // <- destructure
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testVaryingRegionTrackingImmediateScheduling() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write {
|
||||
@@ -172,6 +173,7 @@ class ValueObservationRegionRecordingTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testVaryingRegionTrackingAsyncScheduling() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write {
|
||||
|
||||
@@ -28,6 +28,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testErrorCompletesTheObservation() throws {
|
||||
struct TestError: Error { }
|
||||
|
||||
@@ -79,6 +80,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testViewOptimization() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write {
|
||||
@@ -116,6 +118,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testPragmaTableOptimization() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write {
|
||||
@@ -324,6 +327,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Snapshot Optimization
|
||||
|
||||
@MainActor
|
||||
func testDisallowedSnapshotOptimizationWithAsyncScheduler() throws {
|
||||
let dbPool = try makeDatabasePool()
|
||||
try dbPool.write { db in
|
||||
@@ -366,6 +370,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testDisallowedSnapshotOptimizationWithImmediateScheduler() throws {
|
||||
let dbPool = try makeDatabasePool()
|
||||
try dbPool.write { db in
|
||||
@@ -408,6 +413,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAllowedSnapshotOptimizationWithAsyncScheduler() throws {
|
||||
let dbPool = try makeDatabasePool()
|
||||
try dbPool.write { db in
|
||||
@@ -460,6 +466,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testAllowedSnapshotOptimizationWithImmediateScheduler() throws {
|
||||
let dbPool = try makeDatabasePool()
|
||||
try dbPool.write { db in
|
||||
@@ -584,6 +591,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
|
||||
// MARK: - Cancellation
|
||||
|
||||
@MainActor
|
||||
func testCancellableLifetime() throws {
|
||||
// We need something to change
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
@@ -637,6 +645,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
XCTAssertEqual(context.changesCount, 2)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testCancellableExplicitCancellation() throws {
|
||||
// We need something to change
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
@@ -689,6 +698,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testCancellableInvalidation1() throws {
|
||||
struct Context {
|
||||
var shouldStopObservation = false
|
||||
@@ -741,6 +751,7 @@ class ValueObservationTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testCancellableInvalidation2() throws {
|
||||
struct Context {
|
||||
var shouldStopObservation = false
|
||||
|
||||
Reference in new issue
Block a user