Skip to content

Commit

Permalink
Merge branch 'iOS-Stremable-Functions' of https://github.com/eBlender…
Browse files Browse the repository at this point in the history
…/firebase-ios-sdk into iOS-Stremable-Functions
  • Loading branch information
eBlender committed Jan 16, 2025
2 parents 4ee820e + 9ef7411 commit fd68f01
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions FirebaseFunctions/Tests/Unit/FunctionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ class FunctionsTests: XCTestCase {
XCTExpectFailure("Failed to download stream")
}

func testGenerateStreamContentCanceled() async{
var response = [String]()
let responseQueue = DispatchQueue(label: "responseQueue")
func testGenerateStreamContentCanceled() async {
let options = HTTPSCallableOptions(requireLimitedUseAppCheckTokens: true)
let input: [String: Any] = ["data": "Why is the sky blue"]

Expand All @@ -419,28 +417,25 @@ class FunctionsTests: XCTestCase {
timeout: 4.0
)
// First chunk of the stream comes as NSDictionary
for try await result in stream {
if let dataChunk = result.data as? NSDictionary {
for (key, value) in dataChunk {
responseQueue.sync {
response.append("\(key) \(value)")

}
// Last chunk is the concatenated result so we have to parse it as String else will
// fail.
if let dataString = result.data as? String {
responseQueue.sync {
response.append(dataString)
}
}
var response = [String]()
for try await result in stream {
if let dataChunk = result.data as? NSDictionary {
for (key, value) in dataChunk {
response.append("\(key) \(value)")
}
} else {
// Last chunk is the concatenated result so we have to parse it as String else will
// fail.
if let dataString = result.data as? String {
response.append(dataString)
}
}
// Since we cancel the call we are expecting an empty array.
XCTAssertEqual(
response,
[]
)
}
// Since we cancel the call we are expecting an empty array.
XCTAssertEqual(
response,
[]
)
}
// We cancel the task and we expect a null response even if the stream was initiated.
task.cancel()
Expand Down

0 comments on commit fd68f01

Please sign in to comment.