Repository navigation
test: port the upstream Google tests - #363
Merged
Merged
Conversation
Ports the tests of @ai-sdk/google 4.0.87 (RFC-0045) into aimux-providers/src/google/tests/, one Rust file per upstream test file, one mod per describe level and an `/// upstream:` marker on every test: 438 new tests. With the 58 old tests marked in the next commit, 496 of the 510 in-scope upstream cases have a test (google-language-model.test.ts has two cases named `doGenerate › should pass tools and toolChoice`; the second marker ends in `#2`, RFC-0045 §4). aimux-providers/layout.toml (`[google]`) lists the rest: interactions/, realtime/, speech-translation/, google-batch.ts, download-tool-result-files.ts, google-tools.ts and the tool/*.ts factories are missing (#275), so their 330 cases are not ported; 10 cases are sub-feature (#275: no supportedFunctionResponseUrls, no tool result file download, untyped grounding metadata, no per-batch embedding options transformer, no per-call file upload headers, no ImageResult isRetryable, no transcription usage, no Batch API) and 4 ts-only. Upstream fixtures are copied unchanged into fixtures/, the `toMatchSnapshot` values become snapshots/*.json. `convert_to_google_messages_for_namespace` is widened to `pub(super)` so the tests can convert for the Vertex namespace; the Vertex-provider cases expect no function call ids, as upstream passes `includeFunctionCallIds: !isVertexProvider`. Boundary rules 7c and 8b skip `tests/` folders. The files tests start local wiremock servers (random ports): file upload goes through the validated download path, which never uses an injected transport (registered difference D26). The new tests touch no environment variable and no process-wide state. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
58 old tests that assert everything an upstream @ai-sdk/google 4.0.87 case asserts get its `/// upstream:` marker and move into mods named after its describe chain; their names and bodies are unchanged. 57 `/// partial:` lines point the old tests that cover a case only in part at the full port in src/google/tests/. Old `/// TS:` lines that the markers replace are removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
This was referenced Oct 20, 2026
… into test/port-the-upstream-google-tests Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
The abort tests drop the client mid-upload; on a pooled server the late upload byte reached whichever test borrowed that server next. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
cunninghamcard-bit
marked this pull request as ready for review
October 24, 2026 11:11
6 of 12 tasks
…-transcription-match-the-ai-sdk' into test/port-the-upstream-google-tests
…e-ai-sdk' into test/port-the-upstream-google-tests # Conflicts: # aimux-providers/layout.toml
…e-ai-sdk' into test/port-the-upstream-google-tests # Conflicts: # aimux-providers/layout.toml
…e-ai-sdk' into test/port-the-upstream-google-tests # Conflicts: # aimux-providers/layout.toml
…e-ai-sdk' into test/port-the-upstream-google-tests # Conflicts: # aimux-providers/layout.toml
…e-ai-sdk' into test/port-the-upstream-google-tests
…e-ai-sdk' into test/port-the-upstream-google-tests # Conflicts: # aimux-providers/layout.toml
eric8810
changed the base branch from
fix/google-image-inputs-and-live-transcription-match-the-ai-sdk
to
master
October 27, 2026 04:37
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
按 RFC-0045(#281)把
@ai-sdk/google@4.0.87的上游测试迁完,按厂商分批的第十四个(Mistral #295、Cohere #296、DeepSeek #299、Groq #301、Hugging Face #303、xAI #312、Anthropic AWS #319、Azure #324、Open Responses #347、Google Vertex #352、OpenAI-compatible #355、Amazon Bedrock #358、Anthropic #361)。上游 33 个测试文件共 840 个用例,其中 330 个属于 aimux 没有的模块(下面
missing),在范围内的 510 个:src/google/tests/,一个上游测试文件对应一个 Rust 文件。google-language-model.test.ts里有两个同名用例doGenerate › should pass tools and toolChoice,第二个的标记末尾带#2(RFC-0045 §4)。/// upstream:标记,函数名和函数体不变;另有 57 处旧测试只覆盖了一部分,加了/// partial: …指向完整用例。这部分单独一个提交。layout.toml的 tests 表:sub-feature(Provider 构造与配置:迁移后遗留缺口 #275):没有supportedFunctionResponseUrls(2 个),没有工具结果文件下载downloadToolResultFiles(1 个),grounding metadata 存成无类型 JSON、不做 schema 校验(1 个),embedding 没有按批次变换 provider options 的钩子(1 个),文件上传没有逐次调用的 headers(1 个),aimux-core 的ImageResult没有isRetryable(1 个),TranscriptionResult和转写流的Finish没有usage(2 个),没有 Batch API(1 个)。ts-only:上传数据是同一个Uint8Array视图(对象身份),往uploadFile传 ReadableStream(JS 运行时检查),workflow 序列化钩子,mock 构造函数收到的generateId(上游视频模型从不调用它)。不在范围内的 330 个:
interactions/(194,没有 Interactions 语言模型)、realtime/(84,没有 realtime 模型)、google-batch.ts(27)、speech-translation/(21)、download-tool-result-files.ts(4),文件条目都是missing,挂 #275,用例不迁。迁移中发现 1 处行为差异,修在 #362 里;#362 还带上了 #351 的 Live 转写关闭修复(Google 的转写用例也用到,代码在 Google 共用的转写模块里)。本 PR 叠在它上面:
e3fc27aagemini-2.5-flash-image等三个图片模型报告支持文件输入、不支持 mask0cd2bed5closed unexpectedly before finishing (code, reason)(与 #351 同一改动)一、体系概览:Google 的测试现在怎么跑(master
24977c43)上游
packages/google/src/的 33 个测试文件(用例数):二、本 PR 的改动(细节)
1. 新测试目录(
google/mod.rs末尾#[cfg(test)] mod tests;,:519)2. 这些测试动到的进程级状态
新测试编进
aimux-providers的 lib 测试二进制,和其他模块的单元测试同进程并行跑。它们不读也不改环境变量,没有#[serial],不换进程默认 transport,没有全局计数器,不写临时文件。语言模型、图片、视频、语音、转写、embedding 的用例各用自己的MockFetch(Live 转写用自己的MockWebSocket),需要 URL 的都显式传base_url。files.rs的 11 个用例例外:文件上传走 aimux 校验过的下载路径,这条路不用注入的 transport(D26),所以每个用例起一个本地 wiremock 服务器(127.0.0.1随机端口),base_url指向{server}/v1beta,用例结束服务器随之关闭。和原有的google_files_test.rs用法一样。3.
aimux-providers/layout.toml(只加[google],66 个上游源文件)google-speech-model.test.ts等几个测试文件名和源文件名对不上的,都按源文件登记;.test-d.ts类型测试不列。4. 旧测试的标记(单独一个提交,函数名和函数体不变)
harness 上的差别(期望值都没改,除了下面写明的比法):
new GoogleLanguageModel(...);这里用create_google加api_key、base_url、fetch建。上游 provider 写成google.vertex.chat的用例用GoogleModel::from_config(.., Namespace::Vertex)。includeFunctionCallIds: !isVertexProvider(google-language-model.ts:329),aimux 按Namespace::Vertex决定(convert.rs:428)。convert-to-google-messages里 4 个 Vertex 用例直接调转换函数时上游默认带 id,这里期望值经without_function_call_ids去掉 id 再比,函数注释里写明了原因。content-type和content-length。toMatchObject用递归的子集比较。ai-sdk-google/4.0.87 ai-sdk-provider-utils/5.0.53(上游 mock 成0.0.0-test),单独比。快照里值为undefined的键在 JSON 里省略。currentDate钩子:上游比固定时间戳的地方,这里比时间戳在调用前后之间。types::Candidate能不能解析。Object.prototype,只比累积出的对象(自带__proto__、constructor.prototype键),和上游断言一致。supported-file-url的输入先经url::Url::parse(..).to_string(),和上游new URL(..)得到同样的形式。provider()、model_id()、max_images_per_call()、supported_urls(),以及模型发出的那一个请求的 URL 和 headers。Content-Length"不比,线上客户端总会算出这个头。it.each的各行在一个函数里循环跑。Type of change
Checklist
cargo +1.99 fmt --all -- --checkpassescargo +1.99 clippy -p aimux-providers -p aimux-provider-utils -p aimux-ops --lib --tests --all-features -- -D warningspassescargo +1.99 test -p aimux-providers -p aimux-provider-utils -p aimux-ops --all-features:167 个测试二进制,3266 个测试通过(比 fix: Google image inputs and live transcription match the AI SDK #362 多 438 个)scripts/check_provider_boundaries.shpassesNotes for reviewers
src/test_support/mod.rs、aimux-providers/layout.toml,并改了边界脚本规则 7c、8b 的同两行;这几处在各 PR 里内容相同,后合入的只需合并layout.toml的厂商表。#2),14 个在layout.toml的 tests 表里,330 个属于missing的源文件。Generated by Claude Code