mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-10 22:45:59 +05:45
The Xcode 27.2 SDK (FoundationModels 2.1) adds a `Transcript.Entry.data` case, which triggers a "switch must be exhaustive" warning in `GeminiTranscriptTranslator`. Handle the new case by throwing `unsupportedTranscriptContent`, gated with `canImport(FoundationModels, _version: 2.1)` so only the one case is conditionally compiled and Xcode 27.0 and 27.1 continue to build. Add a unit test for the new case. It requires macOS 27.2 or later at runtime, so it is skipped on earlier OS versions. Add a `unit-tests` job to the GeminiLanguageModel workflow that runs `swift test --skip IntegrationTests` on Xcode 27.0 and 27.2, as well as on Xcode 26.6 (macOS 26) and Xcode 26.2 (macOS 15). The FoundationModels code is compiled out on Xcode 26, so those jobs verify that the package still builds and its remaining tests pass with older toolchains. Update the test READMEs to use `--skip IntegrationTests`, since `--skip Integration` also skips the `IntegrationTestingBackendTests` unit tests.
2.5 KiB
2.5 KiB
GeminiLanguageModel Tests
Unit and integration test suites validating GeminiLanguageModel protocol
conformance, streaming response generation, transcript translation, error
mapping, and backend integration.
Quick Start
# Run all unit tests (fast, ~0.04s, skips integration tests)
swift test --skip IntegrationTests
# Run all tests in this target (including integration tests)
swift test --filter GeminiLanguageModelTests
Test Suites
| Suite / File | Scope | Strategy |
|---|---|---|
GeminiLanguageModelTests.swift |
Protocol conformance, single/multi-turn responses, streaming, tool calling | Unit (MockHTTPURLProtocol) |
GenerationSchema+GeminiTests.swift |
JSON Schema encoding and property ordering conversion | Unit (pure transformation) |
GeminiRequestTranslatorTests.swift |
Request, generation config, tool declarations, and tool mode mapping | Unit (pure transformation) |
GeminiTranscriptTranslatorTests.swift |
Apple Transcript <-> Gemini payload mapping (tools, reasoning, prompts) |
Unit (pure transformation) |
GeminiErrorMapperTests.swift |
HTTP and API error mapping to LanguageModelError |
Unit (exhaustive mapping) |
IntegrationTestingBackendTests.swift |
Endpoint resolution and credential discovery | Unit / Infrastructure |
IntegrationTests/ |
End-to-end Gemini and Firebase AI Logic integration tests | Integration (see IntegrationTests/README.md) |
Testing Architecture
This target separates tests into two distinct tiers:
-
Unit Tests (Default):
- Use
MockHTTPURLProtocolfor deterministic, zero-network, sub-second execution. - Run cleanly in offline, CI, and local development environments without any credentials or background daemons.
- Use
-
Integration Tests (
IntegrationTests/):- Tagged with
.tags(.integration)and gated by.requireIntegrationTestingBackend. - Exercise endpoints on Google Cloud and Firebase using configured credentials.
- Isolated in the
IntegrationTests/subfolder so unit test runs are never slowed down by network timeouts or external dependencies.
- Tagged with
Tip
For details on configuring credentials and parameterizing integration tests, see the Integration Tests Guide.