Skip to content

Commit 782f588

Browse files
committed
[Vertex AI] Switch to GoogleService-Info.plist for snippets tests
1 parent 8328630 commit 782f588

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

FirebaseVertexAI/Tests/Unit/Snippets/FirebaseAppSnippetsUtil.swift

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,19 @@ import Foundation
1717
import XCTest
1818

1919
extension FirebaseApp {
20-
static let projectIDEnvVar = "PROJECT_ID"
21-
static let appIDEnvVar = "APP_ID"
22-
static let apiKeyEnvVar = "API_KEY"
23-
20+
// These snippets are not invoked in CI but may be run manually by placing a
21+
// GoogleService-Info.plist in the the FirebaseVertexAI/Tests/Unit/Resources folder.
2422
static func configureForSnippets() throws {
25-
let environment = ProcessInfo.processInfo.environment
26-
guard let projectID = environment[projectIDEnvVar] else {
27-
throw XCTSkip("No Firebase Project ID specified in environment variable \(projectIDEnvVar).")
28-
}
29-
guard let appID = environment[appIDEnvVar] else {
30-
throw XCTSkip("No Google App ID specified in environment variable \(appIDEnvVar).")
31-
}
32-
guard let apiKey = environment[apiKeyEnvVar] else {
33-
throw XCTSkip("No API key specified in environment variable \(apiKeyEnvVar).")
23+
guard let plistPath = Bundle.module.path(
24+
forResource: "GoogleService-Info",
25+
ofType: "plist"
26+
) else {
27+
throw XCTSkip("No GoogleService-Info.plist found in FirebaseVertexAI/Tests/Unit/Resources.")
3428
}
3529

36-
let options = FirebaseOptions(googleAppID: appID, gcmSenderID: "")
37-
options.projectID = projectID
38-
options.apiKey = apiKey
39-
30+
let options = try XCTUnwrap(FirebaseOptions(contentsOfFile: plistPath))
4031
FirebaseApp.configure(options: options)
32+
4133
guard FirebaseApp.isDefaultAppConfigured() else {
4234
XCTFail("Default Firebase app not configured.")
4335
return

FirebaseVertexAI/Tests/Unit/Snippets/FunctionCallingSnippets.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class FunctionCallingSnippets: XCTestCase {
2323
}
2424

2525
override func tearDown() async throws {
26-
if let app = FirebaseApp.app() {
26+
if FirebaseApp.isDefaultAppConfigured(), let app = FirebaseApp.app() {
2727
await app.delete()
2828
}
2929
}

0 commit comments

Comments
 (0)