-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28f057d
commit f946592
Showing
6 changed files
with
145 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2025 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/// Versions of the Vertex AI in Firebase server API. | ||
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) | ||
// TODO(#14405): Make `APIVersion`, `v1` and `v1beta` public in Firebase 12. | ||
struct APIVersion { | ||
/// The stable channel for version 1 of the API. | ||
static let v1 = APIVersion(versionIdentifier: "v1") | ||
|
||
/// The beta channel for version 1 of the API. | ||
static let v1beta = APIVersion(versionIdentifier: "v1beta") | ||
|
||
let versionIdentifier: String | ||
|
||
init(versionIdentifier: String) { | ||
self.versionIdentifier = versionIdentifier | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2025 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import XCTest | ||
|
||
@testable import FirebaseVertexAI | ||
|
||
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) | ||
final class APIVersionTests: XCTestCase { | ||
func testInitialize_v1() { | ||
let apiVersion: APIVersion = .v1 | ||
|
||
XCTAssertEqual(apiVersion.versionIdentifier, "v1") | ||
} | ||
|
||
func testInitialize_v1beta() { | ||
let apiVersion: APIVersion = .v1beta | ||
|
||
XCTAssertEqual(apiVersion.versionIdentifier, "v1beta") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2025 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import XCTest | ||
|
||
@testable import FirebaseVertexAI | ||
|
||
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) | ||
final class RequestOptionsTests: XCTestCase { | ||
let defaultTimeout: TimeInterval = 180.0 | ||
let defaultAPIVersion = APIVersion.v1beta.versionIdentifier | ||
|
||
func testInitialize_defaultValues() { | ||
let requestOptions = RequestOptions() | ||
|
||
XCTAssertEqual(requestOptions.timeout, defaultTimeout) | ||
XCTAssertEqual(requestOptions.apiVersion, defaultAPIVersion) | ||
} | ||
|
||
func testInitialize_timeout() { | ||
let expectedTimeout = 60.0 | ||
|
||
let requestOptions = RequestOptions(timeout: expectedTimeout) | ||
|
||
XCTAssertEqual(requestOptions.timeout, expectedTimeout) | ||
XCTAssertEqual(requestOptions.apiVersion, defaultAPIVersion) | ||
} | ||
|
||
func testInitialize_apiVersion_v1() { | ||
let requestOptions = RequestOptions(apiVersion: .v1) | ||
|
||
XCTAssertEqual(requestOptions.timeout, defaultTimeout) | ||
XCTAssertEqual(requestOptions.apiVersion, APIVersion.v1.versionIdentifier) | ||
} | ||
|
||
func testInitialize_apiVersion_v1beta() { | ||
let requestOptions = RequestOptions(apiVersion: .v1beta) | ||
|
||
XCTAssertEqual(requestOptions.timeout, defaultTimeout) | ||
XCTAssertEqual(requestOptions.apiVersion, APIVersion.v1beta.versionIdentifier) | ||
} | ||
|
||
func testInitialize_allOptions() { | ||
let expectedTimeout = 30.0 | ||
let expectedAPIVersion = APIVersion.v1 | ||
|
||
let requestOptions = RequestOptions(timeout: expectedTimeout, apiVersion: expectedAPIVersion) | ||
|
||
XCTAssertEqual(requestOptions.timeout, expectedTimeout) | ||
XCTAssertEqual(requestOptions.apiVersion, expectedAPIVersion.versionIdentifier) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters