mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Add a failing test forr #514
This commit is contained in:
1 parent
be950162d0
commit
a6cbd242e6
1 file changed
+36
@@ -152,4 +152,40 @@ class DatabaseRegionObservationTests: GRDBTestCase {
|
||||
|
||||
XCTAssertEqual(count, 1)
|
||||
}
|
||||
|
||||
// Regression test
|
||||
func testIssue514() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write { db in
|
||||
try db.create(table: "gallery") { t in
|
||||
t.column("id", .integer).primaryKey()
|
||||
t.column("status", .integer)
|
||||
}
|
||||
}
|
||||
|
||||
struct Gallery: TableRecord { }
|
||||
let observation = DatabaseRegionObservation(tracking: Gallery.select(Column("id")))
|
||||
|
||||
var notificationCount = 0
|
||||
let observer = try observation.start(in: dbQueue) { _ in
|
||||
notificationCount += 1
|
||||
}
|
||||
|
||||
try withExtendedLifetime(observer) {
|
||||
try dbQueue.write { db in
|
||||
try db.execute(sql: "INSERT INTO gallery (id, status) VALUES (NULL, 0)")
|
||||
}
|
||||
XCTAssertEqual(notificationCount, 1)
|
||||
|
||||
try dbQueue.write { db in
|
||||
try db.execute(sql: "UPDATE gallery SET status = 1")
|
||||
}
|
||||
XCTAssertEqual(notificationCount, 1) // status is not observed
|
||||
|
||||
try dbQueue.write { db in
|
||||
try db.execute(sql: "DELETE FROM gallery")
|
||||
}
|
||||
XCTAssertEqual(notificationCount, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user