|
| 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