mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
map/compactMap fail preserving ValueObservation configuration
This commit is contained in:
1 parent
2c3776d372
commit
3884141fc2
2 files changed
+34
No files matched your search
@@ -59,4 +59,21 @@ class ValueObservationCompactMapTests: GRDBTestCase {
|
||||
try test(makeDatabaseQueue())
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
func testCompactMapPreservesConfiguration() {
|
||||
var observation = ValueObservation.tracking(DatabaseRegion(), fetch: { _ in })
|
||||
observation.extent = .nextTransaction
|
||||
observation.requiresWriteAccess = true
|
||||
observation.scheduling = .unsafe(startImmediately: true)
|
||||
|
||||
let mappedObservation = observation.compactMap { _ in }
|
||||
XCTAssertEqual(mappedObservation.extent, observation.extent)
|
||||
XCTAssertEqual(mappedObservation.requiresWriteAccess, observation.requiresWriteAccess)
|
||||
switch mappedObservation.scheduling {
|
||||
case .unsafe:
|
||||
break
|
||||
default:
|
||||
XCTFail()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,21 @@ class ValueObservationMapTests: GRDBTestCase {
|
||||
try test(makeDatabaseQueue())
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
func testMapPreservesConfiguration() {
|
||||
var observation = ValueObservation.tracking(DatabaseRegion(), fetch: { _ in })
|
||||
observation.extent = .nextTransaction
|
||||
observation.requiresWriteAccess = true
|
||||
observation.scheduling = .unsafe(startImmediately: true)
|
||||
|
||||
let mappedObservation = observation.map { _ in }
|
||||
XCTAssertEqual(mappedObservation.extent, observation.extent)
|
||||
XCTAssertEqual(mappedObservation.requiresWriteAccess, observation.requiresWriteAccess)
|
||||
switch mappedObservation.scheduling {
|
||||
case .unsafe:
|
||||
break
|
||||
default:
|
||||
XCTFail()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user