Repository navigation
test: deduplicate the agent and openai test suites - #422
Open
LarsArtmann wants to merge 3 commits into
Open
LarsArtmann wants to merge 3 commits into
LarsArtmann wants to merge 3 commits into
Conversation
…formats Characterization tests for the code the dedup PRs refactor next: object had no tests at all; the content codecs' provider metadata/options decode and openrouter's reasoning format labels were only pinned implicitly. Each test fails when the branch it covers is disabled.
dupl was not part of the enabled linter set, so clone detection never ran in CI. It now runs at a 75-token threshold, because the default 150 only catches whole-function copies, and the tree is clean at 75: 19 findings, 12 of them real copies. - content_json: the four text and reasoning codecs share one decoder, and the two tool-part marshals share one encoder. - object: the end-of-stream emission becomes one helper, and EmitParsedObject is exported so providers can drop their own copies. - openai: both JSON-mode streamers call EmitParsedObject instead of inlining the parse, validate, repair and emit block. - kronk: the usage fold is shared by Generate and Stream. - Two single-text-part fast paths stay mirrored, with the reason inline. New tests cover object streaming, the codec decoding and the openrouter reasoning label.
dupl ran manually over the tests at the same 75-token threshold charmbracelet#420 uses for production code (CI still excludes tests; that is upstream's own run.tests: false). 103 findings became 69, and the test trees shrank by ~450 lines, by extracting setups rather than merging test cases.
LarsArtmann
force-pushed
the
dedupe-test-suites
branch
from
October 24, 2026 10:12
7817338 to
3c31336
Compare
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.
Stacked on #420. CI does not lint tests (
run.tests: falseis upstream's own setting), so this is a one-time manual pass:duplrun over the tests at the same 75-token threshold #420 uses for production code, fixing what is worth fixing without turning test linting on.103 findings → 69, and the touched test files net −450 lines.
What was extracted
Setups only — no test cases were merged, no assertions moved out of the test that owns them:
agent_test.go/agent_stream_test.go: the repeated mock models became builders —twoStepToolCallModel(request tool, then answer; the image/audio/screenshot/metadata family),scriptedGenerateModel(ordered responses, fails on extra calls, exposes the call count as a getter so the one test that asserts it keeps asserting it),capturingGenerateModel+generateCapture(system-prompt/tool-choice/tool-name capture),verifyingToolCallModel,expectProviderDefinedToolModel,textAndToolCallModel,doneTextStream,streamToolCallStep, andstreamingToolCallModel.providers/openai/openai_test.go: the mock-server harness —newGenerateTestModel,generateAgainstMockServer,streamAgainstMockServer,generateWithUsage, andtestFunctionTool— collapsing the "should send X setting" family (generate and streaming variants) to one call plus its specific assertion.json_test.goandtool_test.gogained small round-trip/media assertion helpers for their flagged pairs.What is deliberately left (the remaining 69)
jsonrepairpairs: parallel repair corpora, likeprompttestin chore: enable the dupl linter and remove the duplication it reports #420.providertestscross-provider scaffolds and the anthropic/openaicompat buckets: shared-suite infrastructure worth its own pass.t.Runscaffolding itself at this threshold.Verification
go test ./... -count=1green exceptproviders/kronk(the locallibffi.so.8panic, unchanged;go test -ccompiles).gofmt,gofumpt,go vet, and the repogolangci-lint run(production, dupl at 75): clean.dupl-with-tests re-measured after each file; the two sibling-row residuals are disclosed above rather than nolint'd.
I have read
CONTRIBUTING.md.I have created a discussion that was approved by a maintainer (for new features).
💘 Generated with Crush