Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
231d602
[Infra] Update functions workflow to use macOS 15 for Xcode 16 jobs (…
eBlender Nov 8, 2024
a14d964
Stremable Functions.
eBlender Dec 20, 2024
a92d7c2
Changed return type.
eBlender Dec 20, 2024
10bec1d
Lint test
eBlender Dec 20, 2024
53a2aab
Remove test function
eBlender Dec 20, 2024
758fbed
Remove old test.
eBlender Dec 20, 2024
93b6c8b
Updated function, add full test.
eBlender Dec 27, 2024
a7e8fe8
Update functions
eBlender Jan 2, 2025
6d59fcd
Update FunctionsTests.swift
eBlender Jan 2, 2025
51f02b8
Cleanup HTTPCallable
eBlender Jan 2, 2025
7b61076
Add documentation for processResponseDataForStreamableContent
eBlender Jan 2, 2025
a95449e
Update Functions.swift
eBlender Jan 2, 2025
cdc49ee
Update Functions.swift
eBlender Jan 2, 2025
426b6bc
Update FunctionsTests.swift
eBlender Jan 2, 2025
9cb0a5e
Update and Cleanup
eBlender Jan 3, 2025
ad31052
Update IntegrationTests.swift
eBlender Jan 3, 2025
6ee9000
Clean up
eBlender Jan 3, 2025
1ffe73d
Update check.sh
eBlender Jan 3, 2025
9fcd91e
Bump to Main.
eBlender Jan 6, 2025
177aa8e
Merge branch 'main' into iOS-Stremable-Functions
eBlender Jan 6, 2025
f4d678b
Cleanup
eBlender Jan 6, 2025
74557e7
Merge branch 'iOS-Stremable-Functions' of https://github.com/eBlender…
eBlender Jan 6, 2025
18f748b
Update Functions.swift
eBlender Jan 7, 2025
4f956fb
Lint check
eBlender Jan 7, 2025
4edc0ad
Function concurrency error
eBlender Jan 7, 2025
e50f69c
Update .github/workflows/functions.yml
eBlender Jan 15, 2025
7356cf9
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Jan 15, 2025
aed47d6
Delete firebase-database-emulator.log
eBlender Jan 15, 2025
f6c6cff
Delete firebase-database-emulator.pid
eBlender Jan 15, 2025
75a7574
Update function error handling.
eBlender Jan 15, 2025
adf7366
Merge branch 'iOS-Stremable-Functions' of https://github.com/eBlender…
eBlender Jan 15, 2025
9ef7411
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Jan 16, 2025
4ee820e
Update FunctionsTests.swift
eBlender Jan 16, 2025
fd68f01
Merge branch 'iOS-Stremable-Functions' of https://github.com/eBlender…
eBlender Jan 16, 2025
f27bf07
Update FunctionsTests.swift
eBlender Jan 16, 2025
1ffa4f0
Format and refactoring.
eBlender Jan 16, 2025
80f0991
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Jan 16, 2025
756dc26
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Jan 16, 2025
f031c1f
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Jan 16, 2025
0df7f8d
Update FirebaseFunctions/Tests/Unit/FunctionsTests.swift
eBlender Jan 16, 2025
3e325aa
[WIP] Add generic and basic streaming implementation
ncooke3 Jan 23, 2025
95fc340
Merge branch 'main' into iOS-Stremable-Functions
ncooke3 Jan 23, 2025
a712525
Merge branch 'main' into iOS-Stremable-Functions
ncooke3 Jan 23, 2025
7b42c35
Move unit tests
ncooke3 Jan 23, 2025
6dc3959
Merge remote-tracking branch 'origin/main' into iOS-Stremable-Functions
ncooke3 Jan 27, 2025
ca53153
Post main sync checkpoint
ncooke3 Jan 27, 2025
d3e476c
Copy over more structure from vertex
ncooke3 Jan 27, 2025
e33f74c
Updated to changes in 14376 so the impl is closer to Vertex on how th…
ncooke3 Jan 29, 2025
b98f71d
Update - remove tests
eBlender Jan 28, 2025
0ea118f
Add Documentation.
eBlender Jan 29, 2025
20892fd
Update Functions.swift
eBlender Jan 29, 2025
83eae53
Update IntegrationTests.swift
eBlender Jan 29, 2025
749b52d
Add more integration tests
ncooke3 Jan 29, 2025
480f7c3
Remove unneeded code
ncooke3 Jan 29, 2025
5587eb7
Fix comments
ncooke3 Jan 29, 2025
078210e
Rename internal stream API
ncooke3 Jan 29, 2025
caeff20
Streamable functions - Continuation of #14395 (#14465)
eBlender Feb 19, 2025
e68b47e
Style and fix TODOs
ncooke3 Feb 19, 2025
2aca67e
Decode StreamResponse
ncooke3 Feb 20, 2025
5fcaf4a
Update integration tests
ncooke3 Feb 21, 2025
e59368e
Intermediate fix for message decoding
ncooke3 Feb 21, 2025
1d75275
emulator backend add test
ncooke3 Feb 21, 2025
4b19247
Custom StreamResponse decoding and add more todos
ncooke3 Feb 21, 2025
b953f58
Don't decode result if stream response is not used
ncooke3 Feb 22, 2025
b8d32c9
Generalize decoding logic
ncooke3 Feb 25, 2025
659a19d
Only decode result in StreamResponse and throw FunctionErrors only
ncooke3 Feb 26, 2025
79b23c9
Resolve TODO & move availability attribute
ncooke3 Feb 26, 2025
5a7275e
Streamable functions api signature change (#14502)
eBlender Feb 26, 2025
1b8b700
Clean up tests following API sig. change
ncooke3 Feb 26, 2025
cb24822
Add changelog entry
ncooke3 Feb 26, 2025
fe17eb2
Remove unreleased API in emulator backend
ncooke3 Feb 26, 2025
10576c1
Remove unneeded availability attribute
ncooke3 Feb 26, 2025
b05d6f3
Resolve more testing TODOs
ncooke3 Feb 26, 2025
9de03a5
refactor private types
ncooke3 Feb 26, 2025
e2cf5f4
Add EmptyRequest type to represent parameter-less CF3
ncooke3 Feb 26, 2025
54967a8
Update doc comment
ncooke3 Feb 26, 2025
84b2950
Remove TODO that is no longer needed
ncooke3 Feb 26, 2025
60b4e6e
Remove unit test related TODO
ncooke3 Feb 26, 2025
672c5ed
Add doc header
ncooke3 Feb 26, 2025
a8313c0
Add doc comment for streamresponse
ncooke3 Feb 26, 2025
f9c557f
Apply suggestions from code review
ncooke3 Feb 27, 2025
2a55348
Review refactor
ncooke3 Feb 27, 2025
949bd63
Remove oos TODO
ncooke3 Feb 27, 2025
53c2560
Shorten test wait time to 100ms
ncooke3 Feb 27, 2025
2d59914
Docs
ncooke3 Feb 27, 2025
3723560
Add more info to doc comment
ncooke3 Feb 27, 2025
9be0b82
Wrap doc comment lines
ncooke3 Feb 27, 2025
3d709d8
Minor changes
ncooke3 Feb 27, 2025
bf21148
Remove unit tests
ncooke3 Feb 27, 2025
28bc4ed
Merge branch 'main' into streamable-functions
ncooke3 Feb 27, 2025
938bccf
Add test for Never
ncooke3 Feb 27, 2025
c9ce046
Add test for streaming non-streaming cf3
ncooke3 Feb 27, 2025
e19fa08
Add more tests
ncooke3 Feb 28, 2025
17f6898
Add top-level comment
ncooke3 Feb 28, 2025
3cf14bf
Add comment
ncooke3 Feb 28, 2025
fba5966
functions.yml
ncooke3 Feb 28, 2025
da798aa
[test] fix ci workaround
ncooke3 Feb 28, 2025
1a376f6
Fix availability check
ncooke3 Feb 28, 2025
ca67754
review (1)
ncooke3 Mar 4, 2025
65455ec
review (2)
ncooke3 Mar 4, 2025
f06ebf0
review (3) - line limit
ncooke3 Mar 4, 2025
9cf8c2c
review (4) - line limit (code)
ncooke3 Mar 4, 2025
887d139
Merge branch 'main' into streamable-functions
ncooke3 Mar 5, 2025
4b4bac6
Merge branch 'main' into streamable-functions
ncooke3 Mar 6, 2025
7e7e5f4
Post merge fix
ncooke3 Mar 6, 2025
f7da23e
Undo change
ncooke3 Mar 6, 2025
36821d0
rename test
ncooke3 Mar 6, 2025
c533101
small nit
ncooke3 Mar 6, 2025
ec33fa8
sendability
ncooke3 Mar 6, 2025
6da863b
Remote --test-spec
ncooke3 Mar 7, 2025
14058ba
Remove downloading iOS sim
ncooke3 Mar 7, 2025
4847a34
review
ncooke3 Mar 7, 2025
2f22696
review 2
ncooke3 Mar 7, 2025
66a7478
visionos ci fix
ncooke3 Mar 7, 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
Prev Previous commit
Next Next commit
Format and refactoring.
Lint.
  • Loading branch information
eBlender committed Jan 16, 2025
commit 1ffa4f07a3b147be233b312a6337404023dfcf44
100 changes: 46 additions & 54 deletions FirebaseFunctions/Tests/Unit/FunctionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -361,48 +361,33 @@

func testGenerateStreamContent() async throws {
let options = HTTPSCallableOptions(requireLimitedUseAppCheckTokens: true)
var response = [String]()
var result = [String]()

let input: [String: Any] = ["data": "Why is the sky blue"]
let stream = try await functions?.stream(
at: URL(string: "http://127.0.0.1:5001/demo-project/us-central1/genStream")!,
withObject: input,
options: options,
timeout: 4.0
)
// First chunk of the stream comes as NSDictionary
if let stream = stream {
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)
}
}
}
XCTAssertEqual(
response,
[
"chunk hello",
"chunk world",
"chunk this",
"chunk is",
"chunk cool",
"hello world this is cool",
]
)
}
XCTExpectFailure("Failed to download stream")
let stream = try await functions!.stream(
at: URL(string: "http://127.0.0.1:5001/demo-project/us-central1/genStream")!,
withObject: input,
options: options,
timeout: 4.0
)
result = try await response(from: stream)
XCTAssertEqual(
result,
[
"chunk hello",
"chunk world",
"chunk this",
"chunk is",
"chunk cool",
"hello world this is cool",
]
)
}

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

let task = Task.detached { [self] in
let stream = try await functions!.stream(
Expand All @@ -411,30 +396,37 @@
options: options,
timeout: 4.0
)
// First chunk of the stream comes as NSDictionary
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)
}
}
}

result = try await response(from: stream)

Check failure on line 400 in FirebaseFunctions/Tests/Unit/FunctionsTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

mutation of captured var 'result' in concurrently-executing code

Check failure on line 400 in FirebaseFunctions/Tests/Unit/FunctionsTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

mutation of captured var 'result' in concurrently-executing code
// Since we cancel the call we are expecting an empty array.
XCTAssertEqual(
response,
result,

Check failure on line 403 in FirebaseFunctions/Tests/Unit/FunctionsTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

reference to captured var 'result' in concurrently-executing code

Check failure on line 403 in FirebaseFunctions/Tests/Unit/FunctionsTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-14, Xcode_15.4, iOS)

reference to captured var 'result' in concurrently-executing code
[]
)
}
// We cancel the task and we expect a null response even if the stream was initiated.
task.cancel()
let result = await task.result
XCTAssertNotNil(result)
let respone = await task.result
XCTAssertNotNil(respone)
}
}

private func response(from stream: AsyncThrowingStream<HTTPSCallableResult,
any Error>) async throws -> [String] {
var response = [String]()
for try await result in stream {

Check failure on line 417 in FirebaseFunctions/Tests/Unit/FunctionsTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.1, macOS)

testGenerateStreamContent, failed: caught error: "Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x6000007389c0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: lo0, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <8062C166-BC04-4847-84CE-BB576275AF16>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
// First chunk of the stream comes as NSDictionary
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)
}
}
}
return response
}
Loading