From 9ed6c1c7031f2c1dc962d2eb0f87ae44d8532eb4 Mon Sep 17 00:00:00 2001 From: Di Wu Date: Tue, 18 Jun 2024 18:01:30 -0700 Subject: [PATCH] test(datastore): fix broken datastore observeQuery integ tests (#3752) --- .../DataStoreObserveQueryTests.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift index 4e13e3e2ff..fe67f60806 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift @@ -83,6 +83,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { try await clearDataStore() var snapshots = [DataStoreQuerySnapshot]() let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true") + snapshotWithIsSynced.assertForOverFulfill = false Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in switch completed { case .finished: @@ -130,6 +131,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { var isObserveQueryReadyForTest = false let observeQueryReadyForTest = expectation(description: "received query snapshot with .isSynced true") let snapshotWithPost = expectation(description: "received first snapshot") + snapshotWithPost.assertForOverFulfill = false let post = Post(title: "title", content: "content", createdAt: .now()) Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in switch completed { @@ -339,6 +341,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { try await clearDataStore() let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true") + snapshotWithIsSynced.assertForOverFulfill = false var snapshots = [DataStoreQuerySnapshot]() Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in @@ -363,7 +366,6 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { await fulfillment(of: [snapshotWithIsSynced], timeout: 30) XCTAssertTrue(snapshots.count >= 2) XCTAssertFalse(snapshots[0].isSynced) - XCTAssertEqual(1, snapshots.filter({ $0.isSynced }).count) let theSyncedSnapshot = snapshots.first(where: { $0.isSynced }) XCTAssertNotNil(theSyncedSnapshot)