Repository navigation
test: port the upstream Groq tests - #301
Merged
Merged
Conversation
The 81 tests in groq_test.rs and groq_transcription_test.rs now sit in one module per upstream describe level, and the 66 that port an upstream case carry a `/// upstream:` marker with the full chain (@ai-sdk/groq 4.0.52). The other 15 are aimux's own and stay at the top level. Test bodies are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
doGenerate › should send request body compares the whole body text, as upstream's inline snapshot does, not two of its fields. The two transcription date cases check that the timestamp is the clock's time during the call; upstream fixes it through _internal.currentDate, which has no Rust counterpart. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
24 upstream cases that call a function directly, in foo/tests.rs next to the function: convertGroqUsage 6, convertToGroqChatMessages 5, groqLanguageModelChatOptions 9, prepareTools 4. Two convertGroqUsage cases fail here (usage.raw drops a null field); the next commit fixes it. One options case checks only the TypeScript type and is listed as ts-only in layout.toml. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
convertGroqUsage (convert-groq-usage.ts:53) returns the usage object as zod parsed it (groq-chat-language-model.ts:564-580): a null field stays null and unknown keys are dropped. aimux re-serialized the typed struct, which dropped null fields, so completion_tokens_details: null or reasoning_tokens: null disappeared from usage.raw. GroqUsage now keeps the parsed object (known keys only) and convert_groq_usage returns it. Tests: groq::usage::tests::convert_groq_usage::should_handle_null_reasoning_tokens_in_completion_tokens_details, should_handle_null_completion_tokens_details. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
13 groq-chat-language-model.test.ts cases in tests/it/groq/, through create_groq and a mock fetch, with the upstream fixtures and snapshots beside them: response information, raw headers, headers, structured output switches, Kimi K2, streamed tool calls and reasoning, the empty chunk after a finished tool call, and the request body. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
[groq] maps the 18 upstream source files of @ai-sdk/groq 4.0.52: 15 to their Rust file, the browserSearch tool factory (groq-tools.ts, tool/browser-search.ts) as missing under #275, version.ts as not applicable. One options case is ts-only. 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
All Groq tests of this port now live in one directory, one file per upstream test file: chat_language_model, chat_language_model_options, convert_to_chat_messages, convert_usage and prepare_tools, with their fixtures/ and snapshots/. The src/groq/*/tests.rs files and the tests/it/ binary are gone; the shared mock fetch is reached through src/test_support/. The boundary script skips files under tests/ dirs as it skips #[cfg(test)] blocks. Test bodies and markers are unchanged. 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
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
cunninghamcard-bit
changed the base branch from
master
to
fix/groq-usage-raw-keeps-null-fields
October 20, 2026 07:03
This was referenced Oct 20, 2026
Merged
…m-groq-tests 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 10:59
6 of 12 tasks
…elds' into test/port-the-upstream-groq-tests
eric8810
reviewed
Oct 25, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Groq test port:多个标为 upstream 的 case 仍是子集断言(text/tool/reasoning/doStream/usage),inline reasoning body 也是裁剪副本;请补完整 snapshots 或收窄“1:1”声明。
Port the doGenerate text, tool-call and reasoning snapshots, the doStream text snapshot, both tool-call streaming inline snapshots and the raw-chunk snapshot to src/groq/tests/chat_language_model.rs with whole-value comparisons. The older tests/ versions of those cases are now marked partial, as are the error-part, unparsable-part and two transcription date cases that cannot match upstream exactly. The remaining tests/ cases now compare the whole request body, usage, tools and warnings, and read the upstream fixtures instead of trimmed inline copies. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Contributor
Author
Generated by Claude Code Generated by Claude Code |
eric8810
approved these changes
Oct 25, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Groq test port 已补全 text/tool/reasoning/stream/usage 的完整 snapshots,fixtures 与上游逐字节一致,98 markers + exclusions 对齐。Approve。
…e-upstream-groq-tests # Conflicts: # aimux-providers/layout.toml
…e-upstream-groq-tests # Conflicts: # aimux-providers/layout.toml
eric8810
changed the base branch from
fix/groq-usage-raw-keeps-null-fields
to
master
October 25, 2026 17:20
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/groq@4.0.52的上游测试迁完,按厂商分批的第四个(Mistral #295、Cohere #296、DeepSeek #299)。上游 6 个测试文件共 104 个用例:
partial:并写明原因:带 provider reference 的文件部分的报错文本(aimux 的UnsupportedFunctionality只带功能名,Provider 构造与配置:迁移后遗留缺口 #275)、流里的 error 部分和无法解析的部分(上游快照的是 JS 的错误对象)、转写模型的两个日期用例(上游靠_internal.currentDate注入固定日期,Rust 侧没有这个入口)。ts-only:只检查 TypeScript 推断出的类型。迁移中发现一处行为差异,单独开了 fix PR #308(上游
usage.raw原样保留值为null的字段,aimux 会把它丢掉),本 PR 叠在它上面。这个修复最早在本分支上提交过,拆出去之后用一个合并提交把 #308 合进来,所以提交列表里还看得到它,但相对 #308 的 diff 只有测试和layout.toml。评审后(
dd9c8013):原有测试里凡是只断言了上游用例一部分的,能补全的都改成整份比较,补不全的标partial::messages/tools/ 请求体 / usage JSON / warnings);json_object 和 strict false 两个用例的输入 schema 补上了上游的$schema。__fixtures__原文件(src/groq/tests/fixtures/)。src/groq/tests/chat_language_model.rs新写完整版本(整个结果与.snap快照或内联快照比,含 response 的 body 和 headers),tests/里的旧版本改标partial:指向它们。旧版本用 wiremock,wiremock 会多加响应头,不能逐字比 headers。位置按新定的布局:Groq 的新测试全放
src/groq/tests/,一个上游测试文件对应一个 Rust 文件。原有的tests/groq_test.rs、tests/groq_transcription_test.rs留在原地,由包拆分线程的搬移 PR 合进来。一、体系概览:Groq 的测试现在怎么跑(master
5743a40a)上游
packages/groq/src/对应:改动前 81 个测试和上游用例对不上号:出处只写了
it文本或改写过的描述,没有 describe 链,有两个标的文本不是上游的it,看不出覆盖了哪些用例。二、本 PR 的改动(细节)
1. 原有 81 个测试补标记(
tests/groq_test.rs、tests/groq_transcription_test.rs)逐个对照场景和断言:66 个对应上游用例,加标记、按
describe包mod,其中 54 个与上游断言完全一致(upstream:),12 个只覆盖一部分(partial:,见上);另外 15 个是 aimux 自己的测试(错误体映射、环境变量读取、x_groqusage 等),放在文件末尾不标;#308 加的 1 个 aimux 测试也在末尾。第一个提交只加标记、函数体不变;之后的提交补全断言(见上)。2. 剩下的上游用例(新目录,
groq/mod.rs末尾#[cfg(test)] mod tests;)3.
aimux-providers/layout.toml(只有[groq])harness 上的差别(期望值都没改):快照里值为
undefined的键在 JSON 里省略;user-agent 检查ai-sdk-groq/4.0.52而不是上游测试里的0.0.0-test;SSE 响应带上 TS 测试服务器的cache-control、connection头;请求体按紧凑 JSON 文本比较(serde_json 开了 preserve_order,键序不变);Uint8Array输入用FileBytes::Binary构造。上游的request.body是 JSON 字符串,aimux 是 JSON 值,快照文件里存解析后的值。Type of change
Checklist
cargo +1.99 fmt -p aimux-providers -- --checkpassescargo +1.99 clippy -p aimux-providers --lib --tests -- -D warningspassescargo +1.99 test -p aimux-providers:lib 172(其中 groq 37)、groq 72、groq_transcription 10,以及用到 Groq 的 cassette_full、conformance、non_object_tool_input、package_user_agent、presets,全过dd9c8013):fmt、clippy、边界检查通过,cargo test -p aimux-providers --lib加groq*测试程序共 3 个、268 个测试全过scripts/check_provider_boundaries.shpassesNotes for reviewers
src/test_support/mod.rs、aimux-providers/layout.toml,并改了边界脚本的同两行;这几处在各 PR 里内容相同,后合入的只需合并layout.toml的厂商表。upstream:标记(44 个在src/groq/tests/,54 个在原有文件),5 个只有partial:标记(原因写在标记里),1 个在layout.toml的 ts-only 里。另有 7 个partial:标记指向有完整测试的用例。https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Generated by Claude Code