Repository navigation
test: port the upstream Cohere tests - #296
Conversation
The 12 existing ports in the embedding and e2e test files now carry an RFC-0045 marker and sit in one mod per upstream describe. Bodies and fn names are unchanged. The e2e embed test checks more than the upstream case that cohere_embedding_test.rs ports, so it no longer claims it; the supportedUrls test is aimux's own and says so. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
All 20 cases of convert-to-cohere-chat-prompt and cohere-prepare-tools (@ai-sdk/cohere@4.0.52) in src/cohere/convert/tests.rs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
49 cases (chat 37, embedding 2, reranking 10) of @ai-sdk/cohere@4.0.52 under tests/it/cohere/, built as the single tests/it/main.rs program; the other 11 are already in cohere_embedding_test.rs and cohere_upstream_e2e_test.rs. Upstream fixtures and snapshots sit beside the tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Maps each upstream source file of @ai-sdk/cohere@4.0.52 to its Rust file (RFC-0046 §4.4) with the RFC-0045 tests table. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
All Cohere tests of this port now live in one directory, one file per upstream test file: chat_language_model, convert_to_chat_prompt, embedding_model, prepare_tools and reranking/reranking_model, with their fixtures/ and snapshots/. src/cohere/convert/tests.rs 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
convert_to_chat_prompt.rs and prepare_tools.rs still wrapped their tests in the module of the old src/cohere/convert/tests.rs. The file is that module now, so only the upstream describe levels stay; the module_inception allow goes with the wrapper. 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
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
eric8810
left a comment
There was a problem hiding this comment.
Cohere test port:generate_text / generate_tool_calls 和 embedding 的 upstream snapshot 只断言了部分 response/header map;请补全 response body/headers 的完整断言,或明确说明缩减。其余 69 个新测试与 fixtures 一致。
…h the whole snapshot eric's review of #296: `should extract text response`, `should extract tool calls` and the embedding `should expose the raw response` asserted only part of upstream's snapshot (selected fields, a trimmed embedding body, one header). They are now ported in src/cohere/tests/ against the .snap entries (snapshots/do_generate_text.json, do_generate_tool_call.json, do_embed_raw_response.json): the whole result, response body and headers included. The older cases in tests/cohere_upstream_e2e_test.rs and tests/cohere_embedding_test.rs stay and carry `partial:` notes pointing at the full ports. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Generated by Claude Code |
eric8810
left a comment
There was a problem hiding this comment.
layout.toml 的 merge 解决错了:mistral 下出现空的 [[mistral.files]],原来的 version.ts not-applicable 行被移到 cohere。请恢复 mistral 的 version.ts 行并删除空 entry。其余测试全量断言和 fixtures 没问题。
The master merge took the shared trailing version.ts lines once, which left an empty [[mistral.files]] entry and moved the Mistral entry under Cohere. layout.toml is now master's file with the Cohere table appended after it, so the diff against master only adds the Cohere table. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
Generated by Claude Code Generated by Claude Code |
eric8810
left a comment
There was a problem hiding this comment.
layout.toml 已恢复 mistral version.ts、删除空 entry;Cohere 表与上游 fixtures/snapshots 精确,80 markers、无 ignore。Approve。
…eam-cohere-tests # Conflicts: # aimux-providers/layout.toml
|
Generated by Claude Code Generated by Claude Code |
…eam-cohere-tests # Conflicts: # aimux-providers/layout.toml
Summary
按 RFC-0045(#281)把
@ai-sdk/cohere@4.0.52的上游测试迁完,是按厂商分批的第二个(第一个是 Mistral,#295)。上游 5 个测试文件共 80 个用例,全部有完整对应的测试并通过:新增 72 个,原有 12 个只改出处标记,没有排除项。原有测试里有 3 个只断言了上游用例的一部分(text、tool call 的生成结果和 embedding 的原始响应),它们改标
partial:,完整断言在src/cohere/tests/的新测试里。不改任何非测试代码。位置按新定的布局:Cohere 的新测试全放
src/cohere/tests/,一个上游测试文件对应一个 Rust 文件。原有的 2 个独立测试文件留在原地,由包拆分线程的搬移 PR 合进来。一、体系概览:Cohere 的测试现在怎么跑(master
5743a40a)上游
packages/cohere/src/对应:改动前 80 个用例里只有 12 个有对应测试("should extract embedding" 还被两个文件各标了一次),出处只写
it文本;两个内部函数文件的 20 个用例一个都没迁。二、本 PR 的改动(细节)
1. 新测试(
src/cohere/mod.rs:273加#[cfg(test)] mod tests;)2. 原有 12 个测试只改标记
函数名、函数体不变,每层
describe包一个mod。其中 3 个只断言了部分 response/header(e2e 的generate_text、generate_tool_calls,embedding 的should_expose_raw_response),标记改为/// partial: `<用例>`; full port in src/cohere/tests/<文件>.rs.;它们用 wiremock,wiremock 会多加响应头,所以整份比较放在用 MockFetch 的新测试里。e2e 文件里的embed_values同时查请求体、向量、用量和原始响应,比上游那个用例多,标记让给cohere_embedding_test.rs的同名测试,自己改成普通注释;chat_supports_http_image_urls测的是supportedUrls,不是上游用例,注释写明是 aimux 自己的测试。3.
aimux-providers/layout.toml(RFC-0046 §4.4 格式,只有[cohere])16 个上游源文件:15 个
mapped(rust是现在的源文件名,搬移 PR 改名时一起改),version.ts为not-applicable。所有tests表为空,没有手写排除。harness 上的差别(期望值都没改):
requestHeaders不含user-agent,比较请求头时去掉。undefined的键在 JSON 里省略。convertToCohereChatPrompt返回的warnings: []:Rust 的convert_prompt_to_cohere不返回告警,改为断言build_request_body的告警为空。PreparedTools没有PartialEq,逐字段比较。options::NAMESPACE(边界检查不许在src/cohere/里写字面量)。Type of change
Checklist
cargo +1.99 fmt --all -- --checkpassescargo +1.99 clippy -p aimux-providers --lib --tests -- -D warningspassescargo +1.99 test -p aimux-providers --lib --test cohere_embedding_test --test cohere_upstream_e2e_test(合入带 test: port the upstream Mistral tests #295 的 master 后、head2cdd716d):3 个测试程序共 304 个,全过(cohere 新测试 72、embedding 5、e2e 8);layout.toml与 master 的[mistral]表合并scripts/check_provider_boundaries.shpassesNotes for reviewers
src/test_support/mod.rs、aimux-providers/layout.toml,并改了边界脚本的同两行;这几处在各 PR 里内容相同,后合入的只需合并layout.toml的厂商表。upstream:标记(72 个在src/cohere/tests/,8 个在原有文件),另有 3 个partial:标记指向有完整测试的用例,没有指向不存在用例的标记。Generated by Claude Code