Skip to content

Commit c9e5d47

Browse files
committed
Add test to try emitting error
1 parent 1d8a316 commit c9e5d47

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ struct GenerateContentIntegrationTests {
4747
storage = Storage.storage()
4848
}
4949

50+
@Test(arguments: InstanceConfig.allConfigs)
51+
func foo(_ config: InstanceConfig) async throws {
52+
throw GenerateContentError
53+
.internalError(
54+
underlying: BackendError(
55+
httpResponseCode: 503,
56+
message: "Backend Overloaded",
57+
status: .unavailable,
58+
details: []
59+
)
60+
)
61+
}
62+
5063
@Test(arguments: InstanceConfig.allConfigs)
5164
func generateContent(_ config: InstanceConfig) async throws {
5265
let model = FirebaseAI.componentInstance(config).generativeModel(

FirebaseAI/Tests/TestApp/Tests/Utilities/IgnoreBackendOverloadedTrait.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ struct IgnoreBackendOverloadedTrait: TestTrait, SuiteTrait, TestScoping {
3030
} matching: { issue in
3131
if case let .internalError(error as BackendError) = issue.error as? GenerateContentError,
3232
error.isServiceUnavailable {
33+
if let sourceLocation = issue.sourceLocation {
34+
print("""
35+
::error file={\(sourceLocation.fileName)},line={\(sourceLocation.line)},\
36+
title={Ignored Backend Overloaded Error}::{\(issue.description)}
37+
""")
38+
}
3339
return true
3440
} else if let error = issue.error as? BackendError, error.isServiceUnavailable {
3541
return true

0 commit comments

Comments
 (0)