From 5f549ef6afa46eaaf7e574767fe3bbeed0256165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 1 Nov 2021 07:22:09 +0100 Subject: [PATCH] Cleanup with Table --- Tests/GRDBTests/ValueObservationFetchTests.swift | 2 +- Tests/GRDBTests/ValueObservationMapTests.swift | 2 +- Tests/GRDBTests/ValueObservationReadonlyTests.swift | 2 +- Tests/GRDBTests/ValueObservationTests.swift | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Tests/GRDBTests/ValueObservationFetchTests.swift b/Tests/GRDBTests/ValueObservationFetchTests.swift index eba1e2e1e..de45ccfb1 100644 --- a/Tests/GRDBTests/ValueObservationFetchTests.swift +++ b/Tests/GRDBTests/ValueObservationFetchTests.swift @@ -196,7 +196,7 @@ class ValueObservationFetchTests: GRDBTestCase { func testRemoveDuplicated() throws { try assertValueObservation( ValueObservation - .trackingConstantRegion { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + .trackingConstantRegion(Table("t").fetchCount) .removeDuplicates(), records: [0, 1, 2], setup: { db in diff --git a/Tests/GRDBTests/ValueObservationMapTests.swift b/Tests/GRDBTests/ValueObservationMapTests.swift index 511cc0395..90e2ea8d5 100644 --- a/Tests/GRDBTests/ValueObservationMapTests.swift +++ b/Tests/GRDBTests/ValueObservationMapTests.swift @@ -4,7 +4,7 @@ import GRDB class ValueObservationMapTests: GRDBTestCase { func testMap() throws { let valueObservation = ValueObservation - .trackingConstantRegion { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + .trackingConstantRegion(Table("t").fetchCount) .map { "\($0)" } try assertValueObservation( diff --git a/Tests/GRDBTests/ValueObservationReadonlyTests.swift b/Tests/GRDBTests/ValueObservationReadonlyTests.swift index 3cff84226..0d3bb0368 100644 --- a/Tests/GRDBTests/ValueObservationReadonlyTests.swift +++ b/Tests/GRDBTests/ValueObservationReadonlyTests.swift @@ -66,7 +66,7 @@ class ValueObservationReadonlyTests: GRDBTestCase { try assertValueObservation( observation, fails: { (_: TestError, writer: DatabaseWriter) in - let count = try writer.read { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + let count = try writer.read(Table("t").fetchCount) XCTAssertEqual(count, 0) }, setup: { db in diff --git a/Tests/GRDBTests/ValueObservationTests.swift b/Tests/GRDBTests/ValueObservationTests.swift index cfee84138..a6f3c720b 100644 --- a/Tests/GRDBTests/ValueObservationTests.swift +++ b/Tests/GRDBTests/ValueObservationTests.swift @@ -530,7 +530,7 @@ class ValueObservationTests: GRDBTestCase { let cancellationExpectation = expectation(description: "cancelled") let observation = ValueObservation - .trackingConstantRegion { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + .trackingConstantRegion(Table("t").fetchCount) .handleEvents(didCancel: { cancellationExpectation.fulfill() }) let task = Task { () -> [Int] in @@ -566,7 +566,7 @@ class ValueObservationTests: GRDBTestCase { let cancellationExpectation = expectation(description: "cancelled") let observation = ValueObservation - .trackingConstantRegion { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + .trackingConstantRegion(Table("t").fetchCount) .handleEvents(didCancel: { cancellationExpectation.fulfill() }) let task = Task { @MainActor () -> [Int] in @@ -602,7 +602,7 @@ class ValueObservationTests: GRDBTestCase { let cancellationExpectation = expectation(description: "cancelled") let observation = ValueObservation - .trackingConstantRegion { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + .trackingConstantRegion(Table("t").fetchCount) .handleEvents(didCancel: { cancellationExpectation.fulfill() }) let task = Task { () -> [Int] in @@ -642,7 +642,7 @@ class ValueObservationTests: GRDBTestCase { let cancellationExpectation = expectation(description: "cancelled") let observation = ValueObservation - .trackingConstantRegion { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + .trackingConstantRegion(Table("t").fetchCount) .handleEvents(didCancel: { cancellationExpectation.fulfill() }) let task = Task { @MainActor () -> [Int] in @@ -680,7 +680,7 @@ class ValueObservationTests: GRDBTestCase { let valueExpectation = expectation(description: "value") valueExpectation.assertForOverFulfill = false let observation = ValueObservation - .trackingConstantRegion { try Int.fetchOne($0, sql: "SELECT COUNT(*) FROM t")! } + .trackingConstantRegion(Table("t").fetchCount) .handleEvents( didReceiveValue: { _ in valueExpectation.fulfill() }, didCancel: { cancellationExpectation.fulfill() })