From 3d3780732f6a64509198ae55fbcb82097773e0e1 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Mon, 22 Jan 2024 14:55:49 -0500 Subject: [PATCH] Add more `defer { task.removeAllObservers() }` in tests --- .../Tests/Integration/StorageIntegration.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/FirebaseStorage/Tests/Integration/StorageIntegration.swift b/FirebaseStorage/Tests/Integration/StorageIntegration.swift index bf21a1809bf..79278d4d991 100644 --- a/FirebaseStorage/Tests/Integration/StorageIntegration.swift +++ b/FirebaseStorage/Tests/Integration/StorageIntegration.swift @@ -244,6 +244,9 @@ class StorageResultTests: StorageIntegrationCommon { self.assertResultSuccess(result) putFileExpectation.fulfill() } + defer { + task.removeAllObservers() + } task.observe(StorageTaskStatus.success) { snapshot in XCTAssertEqual(snapshot.description, "") @@ -292,7 +295,6 @@ class StorageResultTests: StorageIntegrationCommon { self.assertResultSuccess(result) putFileExpectation.fulfill() } - defer { task.removeAllObservers() } @@ -347,7 +349,6 @@ class StorageResultTests: StorageIntegrationCommon { self.assertResultSuccess(result) putFileExpectation.fulfill() } - defer { task.removeAllObservers() } @@ -552,6 +553,9 @@ class StorageResultTests: StorageIntegrationCommon { switch result { case .success: let task = ref.write(toFile: fileURL) + defer { + task.removeAllObservers() + } task.observe(StorageTaskStatus.success) { snapshot in do { @@ -594,6 +598,9 @@ class StorageResultTests: StorageIntegrationCommon { switch result { case .success: let task = ref.write(toFile: fileURL) + defer { + task.removeAllObservers() + } task.observe(StorageTaskStatus.success) { snapshot in XCTFail("Error processing success snapshot") @@ -703,6 +710,9 @@ class StorageResultTests: StorageIntegrationCommon { let fileURL = URL(fileURLWithPath: "\(NSTemporaryDirectory())/hello.txt") let task = ref.write(toFile: fileURL) + defer { + task.removeAllObservers() + } var downloadedBytes: Int64 = 0 var resumeAtBytes = 256 * 1024 @@ -742,6 +752,9 @@ class StorageResultTests: StorageIntegrationCommon { let fileURL = URL(fileURLWithPath: "\(NSTemporaryDirectory())/hello.txt") let task = ref.write(toFile: fileURL) + defer { + task.removeAllObservers() + } var downloadedBytes: Int64 = 0 var resumeAtBytes = 256 * 1024