mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
42 lines
1.4 KiB
Swift
42 lines
1.4 KiB
Swift
import XCTest
|
|
#if GRDBCUSTOMSQLITE
|
|
import GRDBCustomSQLite
|
|
#else
|
|
#if SWIFT_PACKAGE
|
|
import CSQLite
|
|
#else
|
|
import SQLite3
|
|
#endif
|
|
import GRDB
|
|
#endif
|
|
|
|
class ValueObservationCountTests: GRDBTestCase {
|
|
func testCount() throws {
|
|
struct T: TableRecord { }
|
|
let observations = [
|
|
T.all().observationForCount(),
|
|
T.observationForCount()]
|
|
|
|
for observation in observations {
|
|
try assertValueObservation(
|
|
observation,
|
|
records: [0, 1, 2, 3, 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: "UPDATE t SET id = id")
|
|
try db.execute(sql: "INSERT INTO t DEFAULT VALUES")
|
|
try db.inTransaction {
|
|
try db.execute(sql: "INSERT INTO t DEFAULT VALUES")
|
|
try db.execute(sql: "INSERT INTO t DEFAULT VALUES")
|
|
try db.execute(sql: "DELETE FROM t WHERE id = 1")
|
|
return .commit
|
|
}
|
|
try db.execute(sql: "DELETE FROM t WHERE id = 2")
|
|
})
|
|
}
|
|
}
|
|
}
|