Skip to content
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7370352
Add tests to cover new API
eBlender Feb 12, 2025
5d36f3e
Update Tests
eBlender Feb 13, 2025
7f1d359
Update IntegrationTests.swift
eBlender Feb 13, 2025
1e4e0dc
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 18, 2025
1e769cc
Update FirebaseFunctions/Tests/Integration/IntegrationTests.swift
eBlender Feb 18, 2025
05700ea
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 18, 2025
b28c712
Update for CI
eBlender Feb 18, 2025
892a180
Change API stream and Tests.
eBlender Feb 25, 2025
3910d5e
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 25, 2025
2b943f1
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 25, 2025
ca4632c
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 25, 2025
f8f094c
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 25, 2025
934110e
Revert TODO
eBlender Feb 25, 2025
8558021
Merge branch 'streamable-functions' of https://github.com/eBlender/fi…
eBlender Feb 25, 2025
0adbe2a
Update Callable+Codable.swift
eBlender Feb 25, 2025
84c89c4
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Feb 25, 2025
3c35320
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Feb 25, 2025
92cddad
Update FirebaseFunctions/Tests/Integration/IntegrationTests.swift
eBlender Feb 25, 2025
6917002
Update FirebaseFunctions/Tests/Integration/IntegrationTests.swift
eBlender Feb 25, 2025
4c58a2f
Update FirebaseFunctions/Tests/Integration/IntegrationTests.swift
eBlender Feb 25, 2025
c7125e1
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 25, 2025
7c4359a
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Feb 25, 2025
9bd6c73
Update FirebaseFunctions/Tests/Integration/IntegrationTests.swift
eBlender Feb 25, 2025
d5c0ddc
Update FirebaseFunctions/Sources/Callable+Codable.swift
eBlender Feb 25, 2025
9d7e01e
Update FirebaseFunctions/Tests/Integration/IntegrationTests.swift
eBlender Feb 25, 2025
7e88c4d
Merge branch 'streamable-functions' of https://github.com/eBlender/fi…
eBlender Feb 25, 2025
1ebe1a0
Merge branch 'streamable-functions' into streamable-functions
eBlender Feb 25, 2025
c267d0a
Merge branch 'streamable-functions' of https://github.com/eBlender/fi…
eBlender Feb 26, 2025
6934e80
Update IntegrationTests.swift
eBlender Feb 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FirebaseFunctions/Sources/Callable+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ public struct Callable<Request: Encodable, Response: Decodable> {
return try await call(data)
}

public extension Callable {
// TODO: Look into handling parameter-less functions.
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
public func stream(_ data: Request) -> AsyncThrowingStream<Response, Error> {
public func stream(_ data: Request? = nil) -> AsyncThrowingStream<Response, Error> {
return AsyncThrowingStream { continuation in
Task {
do {
Expand Down
31 changes: 29 additions & 2 deletions FirebaseFunctions/Tests/Integration/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ class IntegrationTests: XCTestCase {
)

let result = try await response(from: stream)
// Since we are sending a bad URL we expect an empty array, the reuqets was not a 200.
// Since we are sending a bad URL we expect an empty array, the request was not a 200.
XCTAssertEqual(
result,
[]
Expand All @@ -1007,10 +1007,37 @@ class IntegrationTests: XCTestCase {
)

let result = try await response(from: stream)
XCTFail("TODO: FETCH THE ERROR")
XCTFail("TODO: FETCH THE ERROR")
}
}

@available(iOS 15.0, *)
func testGenStreamContent() async throws {
let callable: Callable<String, StreamResponse<String, String>> = functions.httpsCallable("genStream")
let stream = callable.stream("genStream")
//Todo fetch actual content.
for try await response in stream {
switch response {
case .message(let message):
print("Message: \(message)")
case .result(let result):
print("Result: \(result)")
}
}
}

@available(iOS 15.0, *)
func testGenStream_NoArgs_ThrowsError() async throws {
let callable: Callable<String, StreamResponse<String, String>> = functions.httpsCallable("genStream")
let stream = callable.stream("")
//Todo fetch actual content.
for try await response in stream {
//TODO add logic to fetch the error after we enable
// throw(NSError(domain: "The response cannot be decoded to the given type.", code: 0, userInfo: nil))
// back in Callable+Codable func stream(_ data: Request?=nil) -> AsyncThrowingStream<Response, Error>
}
}

private func response(from stream: AsyncThrowingStream<HTTPSCallableResult,
any Error>) async throws -> [String] {
var response = [String]()
Expand Down
1 change: 1 addition & 0 deletions FirebaseFunctions/Tests/Unit/FunctionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ class FunctionsTests: XCTestCase {
@available(iOS 15, *)
func testGenerateStreamContentCanceled() async {
XCTFail("TODO")
//Implent full tests when stremable<> is ready.
}

@available(iOS 15, *)
Expand Down