Files
GRDB.swift/Tests/GRDBTests/ValueObservation/ValueObservationMapTests.swift
Gwendal Roué 97f517a660 Use Xcode folders
... except in projects that use CocoaPods, because well the new Xcode project format is not supporteed
2026-05-31 23:57:01 +02:00

30 lines
1010 B
Swift

import XCTest
import GRDB
class ValueObservationMapTests: GRDBTestCase {
func testMap() throws {
let valueObservation = ValueObservation
.trackingConstantRegion(Table("t").fetchCount)
.map { "\($0)" }
try assertValueObservation(
valueObservation,
records: ["0", "1", "2"],
setup: { db in
try db.execute(sql: "CREATE TABLE t(id INTEGER PRIMARY KEY AUTOINCREMENT)")
},
recordedUpdates: { db in
try db.execute(sql: "INSERT INTO t DEFAULT VALUES")
try db.execute(sql: "INSERT INTO t DEFAULT VALUES")
})
}
func testMapPreservesConfiguration() {
var observation = ValueObservation.trackingConstantRegion { _ in }
observation.requiresWriteAccess = true
let mappedObservation = observation.map { _ in }
XCTAssertEqual(mappedObservation.requiresWriteAccess, observation.requiresWriteAccess)
}
}