Skip to content

Commit 7709c7c

Browse files
authored
[Firebase AI] Remove v1 integration tests (#14959)
1 parent 4dacdf3 commit 7709c7c

File tree

5 files changed

+12
-69
lines changed

5 files changed

+12
-69
lines changed

FirebaseAI/Tests/TestApp/Tests/Integration/CountTokensIntegrationTests.swift

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,13 @@ struct CountTokensIntegrationTests {
6969
#expect(promptTokensDetails.tokenCount == response.totalTokens)
7070
}
7171

72-
@Test(
73-
/* System instructions are not supported on the v1 Developer API. */
74-
arguments: InstanceConfig.allConfigsExceptGoogleAI_v1
75-
)
72+
@Test(arguments: InstanceConfig.allConfigs)
7673
func countTokens_text_systemInstruction(_ config: InstanceConfig) async throws {
7774
let model = FirebaseAI.componentInstance(config).generativeModel(
7875
modelName: ModelNames.gemini2Flash,
7976
generationConfig: generationConfig,
8077
safetySettings: safetySettings,
81-
systemInstruction: systemInstruction // Not supported on the v1 Developer API
78+
systemInstruction: systemInstruction
8279
)
8380

8481
let response = try await model.countTokens("What is your favourite colour?")
@@ -96,32 +93,7 @@ struct CountTokensIntegrationTests {
9693
#expect(promptTokensDetails.tokenCount == response.totalTokens)
9794
}
9895

99-
@Test(arguments: [
100-
/* System instructions are not supported on the v1 Developer API. */
101-
InstanceConfig.googleAI_v1_freeTier_bypassProxy,
102-
])
103-
func countTokens_text_systemInstruction_unsupported(_ config: InstanceConfig) async throws {
104-
let model = FirebaseAI.componentInstance(config).generativeModel(
105-
modelName: ModelNames.gemini2Flash,
106-
systemInstruction: systemInstruction // Not supported on the v1 Developer API
107-
)
108-
109-
try await #require(
110-
throws: BackendError.self,
111-
"""
112-
If this test fails (i.e., `countTokens` succeeds), remove \(config) from this test and add it
113-
to `countTokens_text_systemInstruction`.
114-
""",
115-
performing: {
116-
try await model.countTokens("What is your favourite colour?")
117-
}
118-
)
119-
}
120-
121-
@Test(
122-
/* System instructions are not supported on the v1 Developer API. */
123-
arguments: InstanceConfig.allConfigsExceptGoogleAI_v1
124-
)
96+
@Test(arguments: InstanceConfig.allConfigs)
12597
func countTokens_jsonSchema(_ config: InstanceConfig) async throws {
12698
let model = FirebaseAI.componentInstance(config).generativeModel(
12799
modelName: ModelNames.gemini2Flash,

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,12 @@ struct GenerateContentIntegrationTests {
4848
}
4949

5050
@Test(arguments: [
51-
(InstanceConfig.vertexAI_v1, ModelNames.gemini2FlashLite),
52-
(InstanceConfig.vertexAI_v1_staging, ModelNames.gemini2FlashLite),
5351
(InstanceConfig.vertexAI_v1beta, ModelNames.gemini2FlashLite),
5452
(InstanceConfig.vertexAI_v1beta_staging, ModelNames.gemini2FlashLite),
5553
(InstanceConfig.googleAI_v1beta, ModelNames.gemini2FlashLite),
5654
(InstanceConfig.googleAI_v1beta, ModelNames.gemma3_4B),
5755
(InstanceConfig.googleAI_v1beta_staging, ModelNames.gemini2FlashLite),
5856
(InstanceConfig.googleAI_v1beta_staging, ModelNames.gemma3_4B),
59-
(InstanceConfig.googleAI_v1_freeTier_bypassProxy, ModelNames.gemini2FlashLite),
6057
(InstanceConfig.googleAI_v1beta_freeTier_bypassProxy, ModelNames.gemini2FlashLite),
6158
(InstanceConfig.googleAI_v1beta_freeTier_bypassProxy, ModelNames.gemma3_4B),
6259
])
@@ -98,19 +95,18 @@ struct GenerateContentIntegrationTests {
9895

9996
@Test(
10097
"Generate an enum and provide a system instruction",
101-
/* System instructions are not supported on the v1 Developer API. */
102-
arguments: InstanceConfig.allConfigsExceptGoogleAI_v1
98+
arguments: InstanceConfig.allConfigs
10399
)
104100
func generateContentEnum(_ config: InstanceConfig) async throws {
105101
let model = FirebaseAI.componentInstance(config).generativeModel(
106102
modelName: ModelNames.gemini2FlashLite,
107103
generationConfig: GenerationConfig(
108-
responseMIMEType: "text/x.enum", // Not supported on the v1 Developer API
104+
responseMIMEType: "text/x.enum",
109105
responseSchema: .enumeration(values: ["Red", "Green", "Blue"])
110106
),
111107
safetySettings: safetySettings,
112-
tools: [], // Not supported on the v1 Developer API
113-
toolConfig: .init(functionCallingConfig: .none()), // Not supported on the v1 Developer API
108+
tools: [],
109+
toolConfig: .init(functionCallingConfig: .none()),
114110
systemInstruction: ModelContent(role: "system", parts: "Always pick blue.")
115111
)
116112
let prompt = "What is your favourite colour?"
@@ -136,7 +132,6 @@ struct GenerateContentIntegrationTests {
136132
}
137133

138134
@Test(arguments: [
139-
InstanceConfig.vertexAI_v1,
140135
InstanceConfig.vertexAI_v1beta,
141136
InstanceConfig.googleAI_v1beta,
142137
InstanceConfig.googleAI_v1beta_staging,
@@ -190,15 +185,12 @@ struct GenerateContentIntegrationTests {
190185
// MARK: Streaming Tests
191186

192187
@Test(arguments: [
193-
(InstanceConfig.vertexAI_v1, ModelNames.gemini2FlashLite),
194-
(InstanceConfig.vertexAI_v1_staging, ModelNames.gemini2FlashLite),
195188
(InstanceConfig.vertexAI_v1beta, ModelNames.gemini2FlashLite),
196189
(InstanceConfig.vertexAI_v1beta_staging, ModelNames.gemini2FlashLite),
197190
(InstanceConfig.googleAI_v1beta, ModelNames.gemini2FlashLite),
198191
(InstanceConfig.googleAI_v1beta, ModelNames.gemma3_4B),
199192
(InstanceConfig.googleAI_v1beta_staging, ModelNames.gemini2FlashLite),
200193
(InstanceConfig.googleAI_v1beta_staging, ModelNames.gemma3_4B),
201-
(InstanceConfig.googleAI_v1_freeTier_bypassProxy, ModelNames.gemini2FlashLite),
202194
(InstanceConfig.googleAI_v1beta_freeTier_bypassProxy, ModelNames.gemini2FlashLite),
203195
(InstanceConfig.googleAI_v1beta_freeTier_bypassProxy, ModelNames.gemma3_4B),
204196
])

FirebaseAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import FirebaseCore
1919
import FirebaseStorage
2020
import XCTest
2121

22-
// TODO(#14405): Migrate to Swift Testing and parameterize tests to run on both `v1` and `v1beta`.
22+
// TODO(#14405): Migrate to Swift Testing and parameterize tests.
2323
final class IntegrationTests: XCTestCase {
2424
// Set temperature, topP and topK to lowest allowed values to make responses more deterministic.
2525
let generationConfig = GenerationConfig(

FirebaseAI/Tests/TestApp/Tests/Integration/SchemaTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct SchemaTests {
4848
storage = Storage.storage()
4949
}
5050

51-
@Test(arguments: InstanceConfig.allConfigsExceptGoogleAI_v1)
51+
@Test(arguments: InstanceConfig.allConfigs)
5252
func generateContentSchemaItems(_ config: InstanceConfig) async throws {
5353
let model = FirebaseAI.componentInstance(config).generativeModel(
5454
modelName: ModelNames.gemini2FlashLite,
@@ -73,7 +73,7 @@ struct SchemaTests {
7373
#expect(decodedJSON.count <= 5, "Expected at most 5 cities, but got \(decodedJSON.count)")
7474
}
7575

76-
@Test(arguments: InstanceConfig.allConfigsExceptGoogleAI_v1)
76+
@Test(arguments: InstanceConfig.allConfigs)
7777
func generateContentSchemaNumberRange(_ config: InstanceConfig) async throws {
7878
let model = FirebaseAI.componentInstance(config).generativeModel(
7979
modelName: ModelNames.gemini2FlashLite,
@@ -96,7 +96,7 @@ struct SchemaTests {
9696
#expect(decodedNumber <= 120.0, "Expected a number <= 120, but got \(decodedNumber)")
9797
}
9898

99-
@Test(arguments: InstanceConfig.allConfigsExceptGoogleAI_v1)
99+
@Test(arguments: InstanceConfig.allConfigs)
100100
func generateContentSchemaNumberRangeMultiType(_ config: InstanceConfig) async throws {
101101
struct ProductInfo: Codable {
102102
let productName: String
@@ -149,7 +149,7 @@ struct SchemaTests {
149149
#expect(rating <= 5, "Expected a rating <= 5, but got \(rating)")
150150
}
151151

152-
@Test(arguments: InstanceConfig.allConfigsExceptGoogleAI_v1)
152+
@Test(arguments: InstanceConfig.allConfigs)
153153
func generateContentAnyOfSchema(_ config: InstanceConfig) async throws {
154154
struct MailingAddress: Decodable {
155155
let streetAddress: String

FirebaseAI/Tests/TestApp/Tests/Utilities/InstanceConfig.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ import Testing
2020
@testable import struct FirebaseAI.APIConfig
2121

2222
struct InstanceConfig: Equatable, Encodable {
23-
static let vertexAI_v1 = InstanceConfig(
24-
apiConfig: APIConfig(service: .vertexAI(endpoint: .firebaseProxyProd), version: .v1)
25-
)
26-
static let vertexAI_v1_staging = InstanceConfig(
27-
apiConfig: APIConfig(service: .vertexAI(endpoint: .firebaseProxyStaging), version: .v1)
28-
)
2923
static let vertexAI_v1beta = InstanceConfig(
3024
apiConfig: APIConfig(service: .vertexAI(endpoint: .firebaseProxyProd), version: .v1beta)
3125
)
@@ -38,33 +32,19 @@ struct InstanceConfig: Equatable, Encodable {
3832
static let googleAI_v1beta_staging = InstanceConfig(
3933
apiConfig: APIConfig(service: .googleAI(endpoint: .firebaseProxyStaging), version: .v1beta)
4034
)
41-
static let googleAI_v1_freeTier_bypassProxy = InstanceConfig(
42-
appName: FirebaseAppNames.spark,
43-
apiConfig: APIConfig(service: .googleAI(endpoint: .googleAIBypassProxy), version: .v1)
44-
)
4535
static let googleAI_v1beta_freeTier_bypassProxy = InstanceConfig(
4636
appName: FirebaseAppNames.spark,
4737
apiConfig: APIConfig(service: .googleAI(endpoint: .googleAIBypassProxy), version: .v1beta)
4838
)
4939

5040
static let allConfigs = [
51-
vertexAI_v1,
52-
vertexAI_v1_staging,
5341
vertexAI_v1beta,
5442
vertexAI_v1beta_staging,
5543
googleAI_v1beta,
5644
googleAI_v1beta_staging,
57-
googleAI_v1_freeTier_bypassProxy,
5845
googleAI_v1beta_freeTier_bypassProxy,
5946
]
60-
static let allConfigsExceptGoogleAI_v1 = allConfigs.filter {
61-
$0 != googleAI_v1_freeTier_bypassProxy
62-
}
6347

64-
static let vertexAI_v1_appCheckNotConfigured = InstanceConfig(
65-
appName: FirebaseAppNames.appCheckNotConfigured,
66-
apiConfig: APIConfig(service: .vertexAI(endpoint: .firebaseProxyProd), version: .v1)
67-
)
6848
static let vertexAI_v1beta_appCheckNotConfigured = InstanceConfig(
6949
appName: FirebaseAppNames.appCheckNotConfigured,
7050
apiConfig: APIConfig(service: .vertexAI(endpoint: .firebaseProxyProd), version: .v1beta)
@@ -75,7 +55,6 @@ struct InstanceConfig: Equatable, Encodable {
7555
)
7656

7757
static let appCheckNotConfiguredConfigs = [
78-
vertexAI_v1_appCheckNotConfigured,
7958
vertexAI_v1beta_appCheckNotConfigured,
8059
googleAI_v1beta_appCheckNotConfigured,
8160
]

0 commit comments

Comments
 (0)