Skip to content

Commit

Permalink
Add more defer { task.removeAllObservers() } in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed Jan 22, 2024
1 parent 9804dd4 commit 3d37807
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions FirebaseStorage/Tests/Integration/StorageIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class StorageResultTests: StorageIntegrationCommon {
self.assertResultSuccess(result)
putFileExpectation.fulfill()
}
defer {
task.removeAllObservers()
}

task.observe(StorageTaskStatus.success) { snapshot in
XCTAssertEqual(snapshot.description, "<State: Success>")
Expand Down Expand Up @@ -292,7 +295,6 @@ class StorageResultTests: StorageIntegrationCommon {
self.assertResultSuccess(result)
putFileExpectation.fulfill()
}

defer {
task.removeAllObservers()
}
Expand Down Expand Up @@ -347,7 +349,6 @@ class StorageResultTests: StorageIntegrationCommon {
self.assertResultSuccess(result)
putFileExpectation.fulfill()
}

defer {
task.removeAllObservers()
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 3d37807

Please sign in to comment.