From ba18626d88cd823f286aa2bb8eaabb6e29021d24 Mon Sep 17 00:00:00 2001 From: Roman Laitarenko Date: Mon, 9 Sep 2024 13:53:00 +0300 Subject: [PATCH] Fix retries for offline integration test case (#2289) --- .../OfflineManagerIntegrationTests.swift | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Tests/MapboxMapsTests/Integration Tests/OfflineManagerIntegrationTests.swift b/Tests/MapboxMapsTests/Integration Tests/OfflineManagerIntegrationTests.swift index d3e0a8394a21..4ca52734eb15 100644 --- a/Tests/MapboxMapsTests/Integration Tests/OfflineManagerIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Integration Tests/OfflineManagerIntegrationTests.swift @@ -189,7 +189,7 @@ final class OfflineManagerIntegrationTestCase: IntegrationTestCase { let loadTileRegionCompletionBlockInvoked = expectation(description: "loadTileRegion completion block invoked") /// Perform the download - tileStore.loadTileRegion( + let tileRegionCancelable = tileStore.loadTileRegion( forId: tileRegionId, loadOptions: tileRegionLoadOptions!, progress: { _ in }, @@ -218,7 +218,7 @@ final class OfflineManagerIntegrationTestCase: IntegrationTestCase { glyphsRasterizationMode: .ideographsRasterizedLocally, metadata: ["tag": "my-outdoors-style-pack"])! - offlineManager.loadStylePack( + let stylePackCancelable = offlineManager.loadStylePack( for: .outdoors, loadOptions: stylePackOptions, completion: { result in @@ -234,15 +234,19 @@ final class OfflineManagerIntegrationTestCase: IntegrationTestCase { } }) - let result = XCTWaiter().wait( - for: [loadStylePackCompletionBlockInvoked, - loadTileRegionCompletionBlockInvoked], - timeout: 120) + let waiter = XCTWaiter() + let expectations: Set = [loadStylePackCompletionBlockInvoked, + loadTileRegionCompletionBlockInvoked] + let result = waiter.wait(for: Array(expectations), timeout: 120) switch result { case .completed: break default: - XCTFail("Expectation failed with \(result). Aborting test.") + tileRegionCancelable.cancel() + stylePackCancelable.cancel() + + let unfullfilledExpectations = expectations.subtracting(Set(waiter.fulfilledExpectations)) + XCTFail("Expectation failed with \(result), unfullfilled expectations: \(unfullfilledExpectations). Aborting test.") abortTest = true } }