From 8b1b3b039656ec89359c2baf41db9b105bb7525e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 19 Apr 2023 08:13:19 +0200 Subject: [PATCH] Fix tests that relied on observation of every single changes --- Tests/GRDBTests/ValueObservationTests.swift | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/GRDBTests/ValueObservationTests.swift b/Tests/GRDBTests/ValueObservationTests.swift index 9be9c044f..f8c49fb7e 100644 --- a/Tests/GRDBTests/ValueObservationTests.swift +++ b/Tests/GRDBTests/ValueObservationTests.swift @@ -769,7 +769,7 @@ class ValueObservationTests: GRDBTestCase { .trackingConstantRegion(Table("t").fetchCount) .handleEvents(didCancel: { cancellationExpectation.fulfill() }) - for try await count in try observation.values(in: writer).prefix(while: { $0 < 3 }) { + for try await count in try observation.values(in: writer).prefix(while: { $0 <= 3 }) { counts.append(count) try await writer.write { try $0.execute(sql: "INSERT INTO t DEFAULT VALUES") } } @@ -777,9 +777,9 @@ class ValueObservationTests: GRDBTestCase { } let counts = try await task.value - - // All values were published - assertValueObservationRecordingMatch(recorded: counts, expected: [0, 1, 2]) + XCTAssertTrue(counts.contains(0)) + XCTAssertTrue(counts.contains(where: { $0 >= 2 })) + XCTAssertEqual(counts.sorted(), counts) // Observation was ended #if compiler(>=5.8) @@ -807,7 +807,7 @@ class ValueObservationTests: GRDBTestCase { .trackingConstantRegion(Table("t").fetchCount) .handleEvents(didCancel: { cancellationExpectation.fulfill() }) - for try await count in try observation.values(in: writer, scheduling: .immediate).prefix(while: { $0 < 3 }) { + for try await count in try observation.values(in: writer, scheduling: .immediate).prefix(while: { $0 <= 3 }) { counts.append(count) try await writer.write { try $0.execute(sql: "INSERT INTO t DEFAULT VALUES") } } @@ -815,9 +815,9 @@ class ValueObservationTests: GRDBTestCase { } let counts = try await task.value - - // All values were published - assertValueObservationRecordingMatch(recorded: counts, expected: [0, 1, 2]) + XCTAssertTrue(counts.contains(0)) + XCTAssertTrue(counts.contains(where: { $0 >= 2 })) + XCTAssertEqual(counts.sorted(), counts) // Observation was ended #if compiler(>=5.8) @@ -847,7 +847,7 @@ class ValueObservationTests: GRDBTestCase { for try await count in observation.values(in: writer) { counts.append(count) - if count == 2 { + if count > 3 { break } else { try await writer.write { try $0.execute(sql: "INSERT INTO t DEFAULT VALUES") } @@ -857,9 +857,9 @@ class ValueObservationTests: GRDBTestCase { } let counts = try await task.value - - // All values were published - assertValueObservationRecordingMatch(recorded: counts, expected: [0, 1, 2]) + XCTAssertTrue(counts.contains(0)) + XCTAssertTrue(counts.contains(where: { $0 >= 2 })) + XCTAssertEqual(counts.sorted(), counts) // Observation was ended #if compiler(>=5.8)