From bb045235bfd346c22f050c7ddb30f640870f240c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 8 Feb 2019 10:15:49 +0100 Subject: [PATCH] Remove tests for deprecated methods --- .../ValueObservationFetchTests.swift | 35 ---------------- .../ValueObservationReducerTests.swift | 41 ------------------- 2 files changed, 76 deletions(-) diff --git a/Tests/GRDBTests/ValueObservationFetchTests.swift b/Tests/GRDBTests/ValueObservationFetchTests.swift index e4755699a..019abc851 100644 --- a/Tests/GRDBTests/ValueObservationFetchTests.swift +++ b/Tests/GRDBTests/ValueObservationFetchTests.swift @@ -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)") } diff --git a/Tests/GRDBTests/ValueObservationReducerTests.swift b/Tests/GRDBTests/ValueObservationReducerTests.swift index af94a5180..714d0a0d4 100644 --- a/Tests/GRDBTests/ValueObservationReducerTests.swift +++ b/Tests/GRDBTests/ValueObservationReducerTests.swift @@ -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