From 9bfa5168249a36681b6b988df4b570ccf566d1b0 Mon Sep 17 00:00:00 2001 From: Tomasz Trela Date: Sat, 2 Mar 2024 12:19:54 +0100 Subject: [PATCH] test wip --- ...AsyncSubscriptionEventPublisherTests.swift | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisherTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisherTests.swift index 48100ba687..0378865a37 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisherTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/SubscriptionSync/IncomingAsyncSubscriptionEventPublisherTests.swift @@ -106,4 +106,53 @@ final class IncomingAsyncSubscriptionEventPublisherTests: XCTestCase { XCTAssertEqual(expectedOrder.get(), actualOrder.get()) sink.cancel() } + + func testBaseQueryWithSyncExpressionConstantAll() async throws { + + DataStoreConfiguration.custom() + let expectedEvents = expectation(description: "Expected number of ") + + let responder = SubscribeRequestListenerResponder> {request, valueListener, _ in + if request.document.contains("onUpdateMockSynced") { + print() + } + HERE TUTUAJ TEST + return nil + } + + apiPlugin.responders[.subscribeRequestListener] = responder + + let asyncEvents = await IncomingAsyncSubscriptionEventPublisher( + modelSchema: Post.schema, + api: apiPlugin, + modelPredicate: QueryPredicateGroup(type: .or, predicates: [ + Post.keys.id.eq("a"), + Post.keys.id.eq("b") + ]), + auth: nil, + authModeStrategy: AWSDefaultAuthModeStrategy(), + awsAuthService: nil) + let mapper = IncomingAsyncSubscriptionEventToAnyModelMapper() + + asyncEvents.subscribe(subscriber: mapper) + let sink = mapper + .publisher + .sink( + receiveCompletion: { _ in }, + receiveValue: { event in + switch event { + case .payload(let mutationSync): + print() +// actualOrder.append(mutationSync.syncMetadata.modelId) + default: + break + } + print() +// expectedEvents.fulfill() + } + ) + + await fulfillment(of: [expectedEvents], timeout: 2) + sink.cancel() + } }