Skip to content

Commit 167f385

Browse files
committed
review
1 parent 5b68c7b commit 167f385

File tree

5 files changed

+37
-29
lines changed

5 files changed

+37
-29
lines changed

FirebaseVertexAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,7 @@ struct GenerateContentIntegrationTests {
4343
let userID1: String
4444

4545
init() async throws {
46-
if let user = Auth.auth().currentUser {
47-
userID1 = user.uid
48-
} else {
49-
let authResult = try await Auth.auth().signIn(
50-
withEmail: Credentials.emailAddress1,
51-
password: Credentials.emailPassword1
52-
)
53-
userID1 = authResult.user.uid
54-
}
46+
userID1 = try await TestHelpers.getUserID()
5547
storage = Storage.storage()
5648
}
5749

FirebaseVertexAI/Tests/TestApp/Tests/Integration/ImagenIntegrationTests.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,7 @@ struct ImagenIntegrationTests {
3939
var userID1: String
4040

4141
init() async throws {
42-
if let user = Auth.auth().currentUser {
43-
userID1 = user.uid
44-
} else {
45-
let authResult = try await Auth.auth().signIn(
46-
withEmail: Credentials.emailAddress1,
47-
password: Credentials.emailPassword1
48-
)
49-
userID1 = authResult.user.uid
50-
}
51-
42+
userID1 = try await TestHelpers.getUserID()
5243
vertex = VertexAI.vertexAI()
5344
storage = Storage.storage()
5445
}

FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,7 @@ final class IntegrationTests: XCTestCase {
4848
var userID1 = ""
4949

5050
override func setUp() async throws {
51-
if let user = Auth.auth().currentUser {
52-
userID1 = user.uid
53-
} else {
54-
let authResult = try await Auth.auth().signIn(
55-
withEmail: Credentials.emailAddress1,
56-
password: Credentials.emailPassword1
57-
)
58-
userID1 = authResult.user.uid
59-
}
60-
51+
userID1 = try await TestHelpers.getUserID()
6152
vertex = VertexAI.vertexAI()
6253
model = vertex.generativeModel(
6354
modelName: "gemini-2.0-flash",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import FirebaseAuth
16+
import FirebaseCore
17+
18+
enum TestHelpers {
19+
static func getUserID() async throws -> String {
20+
if let user = Auth.auth().currentUser {
21+
return user.uid
22+
} else {
23+
let authResult = try await Auth.auth().signIn(
24+
withEmail: Credentials.emailAddress1,
25+
password: Credentials.emailPassword1
26+
)
27+
return authResult.user.uid
28+
}
29+
}
30+
}

FirebaseVertexAI/Tests/TestApp/VertexAITestApp.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
86D77DFE2D7B5C86003D155D /* GoogleService-Info-Spark.plist in Resources */ = {isa = PBXBuildFile; fileRef = 86D77DFD2D7B5C86003D155D /* GoogleService-Info-Spark.plist */; };
2828
86D77E022D7B63AF003D155D /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86D77E012D7B63AC003D155D /* Constants.swift */; };
2929
86D77E042D7B6C9D003D155D /* InstanceConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86D77E032D7B6C95003D155D /* InstanceConfig.swift */; };
30+
DEF0BB4F2DA74F680093E9F4 /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEF0BB4E2DA74F460093E9F4 /* TestHelpers.swift */; };
3031
/* End PBXBuildFile section */
3132

3233
/* Begin PBXContainerItemProxy section */
@@ -59,6 +60,7 @@
5960
86D77DFD2D7B5C86003D155D /* GoogleService-Info-Spark.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info-Spark.plist"; sourceTree = "<group>"; };
6061
86D77E012D7B63AC003D155D /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
6162
86D77E032D7B6C95003D155D /* InstanceConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstanceConfig.swift; sourceTree = "<group>"; };
63+
DEF0BB4E2DA74F460093E9F4 /* TestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestHelpers.swift; sourceTree = "<group>"; };
6264
/* End PBXFileReference section */
6365

6466
/* Begin PBXFrameworksBuildPhase section */
@@ -137,6 +139,7 @@
137139
868A7C572CCC27AF00E449DD /* Integration */ = {
138140
isa = PBXGroup;
139141
children = (
142+
DEF0BB4E2DA74F460093E9F4 /* TestHelpers.swift */,
140143
8689CDCB2D7F8BCF00BF426B /* CountTokensIntegrationTests.swift */,
141144
868A7C4D2CCC1F4700E449DD /* Credentials.swift */,
142145
8661386D2CC943DE00F4B78E /* IntegrationTests.swift */,
@@ -289,6 +292,7 @@
289292
files = (
290293
8689CDCC2D7F8BD700BF426B /* CountTokensIntegrationTests.swift in Sources */,
291294
86D77E042D7B6C9D003D155D /* InstanceConfig.swift in Sources */,
295+
DEF0BB4F2DA74F680093E9F4 /* TestHelpers.swift in Sources */,
292296
868A7C4F2CCC229F00E449DD /* Credentials.swift in Sources */,
293297
864F8F712D4980DD0002EA7E /* ImagenIntegrationTests.swift in Sources */,
294298
862218812D04E098007ED2D4 /* IntegrationTestUtils.swift in Sources */,

0 commit comments

Comments
 (0)