mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Remove tests for deprecated methods
This commit is contained in:
1 parent
ca4879c496
commit
bb045235bf
2 files changed
-76
No files matched your search
@@ -16,10 +16,8 @@ class ValueObservationFetchTests: GRDBTestCase {
|
||||
func testRegionsAPI() {
|
||||
// single region
|
||||
_ = ValueObservation.tracking(DatabaseRegion(), fetch: { _ in })
|
||||
_ = ValueObservation.tracking(DatabaseRegion(), fetchDistinct: { _ in 0 })
|
||||
// variadic
|
||||
_ = ValueObservation.tracking(DatabaseRegion(), DatabaseRegion(), fetch: { _ in })
|
||||
_ = ValueObservation.tracking(DatabaseRegion(), DatabaseRegion(), fetchDistinct: { _ in 0 })
|
||||
// array
|
||||
_ = ValueObservation.tracking([DatabaseRegion()], fetch: { _ in })
|
||||
}
|
||||
@@ -56,39 +54,6 @@ class ValueObservationFetchTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
// Test for a deprecated API
|
||||
func testFetchDistinct() throws {
|
||||
func test(_ dbWriter: DatabaseWriter) throws {
|
||||
try dbWriter.write { try $0.execute("CREATE TABLE t(id INTEGER PRIMARY KEY AUTOINCREMENT)") }
|
||||
|
||||
var counts: [Int] = []
|
||||
let notificationExpectation = expectation(description: "notification")
|
||||
notificationExpectation.assertForOverFulfill = true
|
||||
notificationExpectation.expectedFulfillmentCount = 3
|
||||
|
||||
var observation = ValueObservation.tracking(DatabaseRegion.fullDatabase, fetchDistinct: {
|
||||
try Int.fetchOne($0, "SELECT COUNT(*) FROM t")!
|
||||
})
|
||||
observation.extent = .databaseLifetime
|
||||
_ = try observation.start(in: dbWriter) { count in
|
||||
counts.append(count)
|
||||
notificationExpectation.fulfill()
|
||||
}
|
||||
|
||||
try dbWriter.writeWithoutTransaction { db in
|
||||
try db.execute("INSERT INTO t DEFAULT VALUES")
|
||||
try db.execute("UPDATE t SET id = id")
|
||||
try db.execute("INSERT INTO t DEFAULT VALUES")
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(counts, [0, 1, 2])
|
||||
}
|
||||
|
||||
try test(makeDatabaseQueue())
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
func testDistinctUntilChanged() throws {
|
||||
func test(_ dbWriter: DatabaseWriter) throws {
|
||||
try dbWriter.write { try $0.execute("CREATE TABLE t(id INTEGER PRIMARY KEY AUTOINCREMENT)") }
|
||||
|
||||
@@ -205,47 +205,6 @@ class ValueObservationReducerTests: GRDBTestCase {
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
func testDeprecatedReadMeReducer() throws {
|
||||
func test(_ dbWriter: DatabaseWriter) throws {
|
||||
// Test for the reducer documented in the main README
|
||||
|
||||
// We need something to change
|
||||
try dbWriter.write { try $0.execute("CREATE TABLE t(id INTEGER PRIMARY KEY AUTOINCREMENT)") }
|
||||
|
||||
// Track reducer process
|
||||
var counts: [Int] = []
|
||||
let notificationExpectation = expectation(description: "notification")
|
||||
notificationExpectation.assertForOverFulfill = true
|
||||
notificationExpectation.expectedFulfillmentCount = 2
|
||||
|
||||
// Create an observation
|
||||
var count = 0
|
||||
let reducer = AnyValueReducer(
|
||||
fetch: { _ in /* don't fetch anything */ },
|
||||
value: { _ -> Int? in
|
||||
defer { count += 1 }
|
||||
return count })
|
||||
var observation = ValueObservation.tracking(DatabaseRegion.fullDatabase, reducer: reducer)
|
||||
observation.extent = .databaseLifetime
|
||||
|
||||
// Start observation
|
||||
_ = try observation.start(in: dbWriter) { count in
|
||||
counts.append(count)
|
||||
notificationExpectation.fulfill()
|
||||
}
|
||||
|
||||
try dbWriter.write { db in
|
||||
try db.execute("INSERT INTO t DEFAULT VALUES")
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
XCTAssertEqual(counts, [0, 1])
|
||||
}
|
||||
|
||||
try test(makeDatabaseQueue())
|
||||
try test(makeDatabasePool())
|
||||
}
|
||||
|
||||
func testReadMeReducer() throws {
|
||||
func test(_ dbWriter: DatabaseWriter) throws {
|
||||
// Test for the reducer documented in the main README
|
||||
|
||||
Reference in new issue
Block a user