From 4e4c7472c6219640b3d1cb4f4cbd05a5c04d0052 Mon Sep 17 00:00:00 2001 From: Liu Liu Date: Fri, 10 Jun 2022 15:12:48 -0400 Subject: [PATCH] Fix bufferingPolicy not passed in. --- src/sqlite/SQLiteWorkspace.swift | 4 ++-- src/tests/AsyncTests.swift | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sqlite/SQLiteWorkspace.swift b/src/sqlite/SQLiteWorkspace.swift index 890e066f2..07115a5d6 100644 --- a/src/sqlite/SQLiteWorkspace.swift +++ b/src/sqlite/SQLiteWorkspace.swift @@ -526,7 +526,7 @@ public final class SQLiteWorkspace: Workspace { public func subscribe( object: Element, bufferingPolicy: AsyncStream.Continuation.BufferingPolicy ) -> AsyncStream { - AsyncStream { continuation in + AsyncStream(bufferingPolicy: bufferingPolicy) { continuation in let cancellable = self.subscribe(object: object) { object in switch object { case .deleted: @@ -546,7 +546,7 @@ public final class SQLiteWorkspace: Workspace { fetchedResult: FetchedResult, bufferingPolicy: AsyncStream>.Continuation.BufferingPolicy ) -> AsyncStream> { - AsyncStream { continuation in + AsyncStream(bufferingPolicy: bufferingPolicy) { continuation in let cancellable = self.subscribe(fetchedResult: fetchedResult) { fetchedResult in continuation.yield(fetchedResult) } diff --git a/src/tests/AsyncTests.swift b/src/tests/AsyncTests.swift index c6aab2d22..81bb44932 100644 --- a/src/tests/AsyncTests.swift +++ b/src/tests/AsyncTests.swift @@ -144,14 +144,13 @@ class AsyncTests: XCTestCase { MyGame.Sample.Monster.mana <= 50, orderBy: [MyGame.Sample.Monster.mana.ascending]) XCTAssertEqual(fetchedResult.count, 6) let subscribeTask = Task { () -> FetchedResult in - var updateCount = 0 var updatedFetchedResult = fetchedResult for await newFetchedResult in dflat.subscribe( fetchedResult: fetchedResult, bufferingPolicy: .unbounded) { updatedFetchedResult = newFetchedResult - updateCount += 1 - if updateCount == 4 { + if newFetchedResult.first(where: { $0.name == "name 3" }) == nil { + // We've deleted this one, that's the last mutation, exit. break } }