Skip to content

Commit 17faaf8

Browse files
committed
Add unit tests for Backend
1 parent 1b6b391 commit 17faaf8

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

FirebaseAI/Sources/Types/Public/Backend.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,3 @@ public struct Backend {
4848
self.location = location
4949
}
5050
}
51-
52-
extension Backend: Equatable {}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 XCTest
16+
17+
@testable import FirebaseAI
18+
19+
final class BackendTests: XCTestCase {
20+
func testVertexAI_defaultLocation() {
21+
let expectedAPIConfig = APIConfig(
22+
service: .vertexAI(endpoint: .firebaseVertexAIProd),
23+
version: .v1beta
24+
)
25+
26+
let backend = Backend.vertexAI()
27+
28+
XCTAssertEqual(backend.apiConfig, expectedAPIConfig)
29+
XCTAssertEqual(backend.location, "us-central1")
30+
}
31+
32+
func testVertexAI_customLocation() {
33+
let expectedAPIConfig = APIConfig(
34+
service: .vertexAI(endpoint: .firebaseVertexAIProd),
35+
version: .v1beta
36+
)
37+
let customLocation = "europe-west1"
38+
39+
let backend = Backend.vertexAI(location: customLocation)
40+
41+
XCTAssertEqual(backend.apiConfig, expectedAPIConfig)
42+
XCTAssertEqual(backend.location, customLocation)
43+
}
44+
45+
func testGoogleAI() {
46+
let expectedAPIConfig = APIConfig(
47+
service: .developer(endpoint: .firebaseVertexAIProd),
48+
version: .v1beta
49+
)
50+
51+
let backend = Backend.googleAI()
52+
53+
XCTAssertEqual(backend.apiConfig, expectedAPIConfig)
54+
XCTAssertNil(backend.location)
55+
}
56+
}

0 commit comments

Comments
 (0)