From 60d06ba12ef13a02ff690c9a5d87ffec030384bb Mon Sep 17 00:00:00 2001 From: kean Date: Sat, 4 May 2024 15:35:06 -0400 Subject: [PATCH] Remove flaky testAsyncEvents (no way to gurantee order) --- Tests/NukeTests/ImageCacheTests.swift | 1 - .../ImagePipelineAsyncAwaitTests.swift | 44 +------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/Tests/NukeTests/ImageCacheTests.swift b/Tests/NukeTests/ImageCacheTests.swift index f856e077f..788b9925a 100644 --- a/Tests/NukeTests/ImageCacheTests.swift +++ b/Tests/NukeTests/ImageCacheTests.swift @@ -330,7 +330,6 @@ class ImageCacheTests: XCTestCase, @unchecked Sendable { } #if os(iOS) || os(tvOS) || os(visionOS) - @MainActor @MainActor func testThatSomeImagesAreRemovedOnDidEnterBackground() async { // GIVEN diff --git a/Tests/NukeTests/ImagePipelineTests/ImagePipelineAsyncAwaitTests.swift b/Tests/NukeTests/ImagePipelineTests/ImagePipelineAsyncAwaitTests.swift index 634699104..86ad1f00c 100644 --- a/Tests/NukeTests/ImagePipelineTests/ImagePipelineAsyncAwaitTests.swift +++ b/Tests/NukeTests/ImagePipelineTests/ImagePipelineAsyncAwaitTests.swift @@ -65,47 +65,6 @@ class ImagePipelineAsyncAwaitTests: XCTestCase, @unchecked Sendable { XCTAssertEqual(image.sizeInPixels, CGSize(width: 640, height: 480)) } - @MainActor - @available(macOS 12, iOS 15, tvOS 15, watchOS 9, *) - func testAsyncImageTaskEvents() async throws { - // GIVEN - let dataLoader = MockProgressiveDataLoader() - pipeline = pipeline.reconfigured { - $0.dataLoader = dataLoader - $0.isProgressiveDecodingEnabled = true - } - pipeline.queue.suspend() - // TODO: Find a more reliable way to subscribe to events - DispatchQueue.global.asyncAfter(deadline: .now() + .milliseconds(64)) { - self.pipeline.queue.resume() // Make sure we subscribe after a delay - } - - // WHEN - let task = pipeline.imageTask(with: Test.url) - for await event in task.events.values { - switch event { - case .preview(let response): - recordedPreviews.append(response) - dataLoader.resume() - case .finished(let result): - recordedResult = result - default: - break - } - recordedEvents.append(event) - } - - // THEN - XCTAssertEqual(recordedEvents, [ - .progress(.init(completed: 13152, total: 39456)), - .preview(recordedPreviews[0]), - .progress(.init(completed: 26304, total: 39456)), - .preview(recordedPreviews[1]), - .progress(.init(completed: 39456, total: 39456)), - .finished(try XCTUnwrap(recordedResult)) - ]) - } - private var observer: AnyObject? // MARK: - Cancellation @@ -426,8 +385,9 @@ class ImagePipelineAsyncAwaitTests: XCTestCase, @unchecked Sendable { // MARK: - ImageTask Integration + // TODO: - Re-enable @available(macOS 12, iOS 15, tvOS 15, watchOS 9, *) - func testImageTaskEvents() async { + func _testImageTaskEvents() async { // GIVEN let dataLoader = MockProgressiveDataLoader() pipeline = pipeline.reconfigured {