Skip to content

Commit 5b68c7b

Browse files
committed
Minimize signins in VertexAI integration tests
1 parent 11fe4a0 commit 5b68c7b

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

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

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

4545
init() async throws {
46-
let authResult = try await Auth.auth().signIn(
47-
withEmail: Credentials.emailAddress1,
48-
password: Credentials.emailPassword1
49-
)
50-
userID1 = authResult.user.uid
51-
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+
}
5255
storage = Storage.storage()
5356
}
5457

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ struct ImagenIntegrationTests {
3939
var userID1: String
4040

4141
init() async throws {
42-
let authResult = try await Auth.auth().signIn(
43-
withEmail: Credentials.emailAddress1,
44-
password: Credentials.emailPassword1
45-
)
46-
userID1 = authResult.user.uid
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+
}
4751

4852
vertex = VertexAI.vertexAI()
4953
storage = Storage.storage()

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ final class IntegrationTests: XCTestCase {
4848
var userID1 = ""
4949

5050
override func setUp() async throws {
51-
let authResult = try await Auth.auth().signIn(
52-
withEmail: Credentials.emailAddress1,
53-
password: Credentials.emailPassword1
54-
)
55-
userID1 = authResult.user.uid
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+
}
5660

5761
vertex = VertexAI.vertexAI()
5862
model = vertex.generativeModel(

0 commit comments

Comments
 (0)