[integrations][gemini] Cover buildConfig with unit tests - #1096
Open
weiqingy wants to merge 1 commit into
Open
Conversation
GeminiChatModelConnection.buildConfig assembles the GenerateContentConfig for every Gemini request -- system instruction, sampling parameters, additional kwargs and tool declarations -- and had no test coverage. Widen it to package-private, matching the convention already used by five other members of the class, and add four tests. Three production writes were reachable but unasserted, so the tests assert the tool declaration's description and parametersJsonSchema, and the part count that detects a user turn leaking into the system instruction. The dispatch from buildConfig to applyAdditionalKwargs was previously uncovered: the existing applyAdditionalKwargs tests each call that method directly on a builder they construct. Generated-by: Claude Code 2.1.259 (Claude Opus 5)
5 tasks
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.
Linked issue: #280
Purpose of change
GeminiChatModelConnection.buildConfigassembles the request configuration for every Gemini call: the system instruction, sampling parameters, forwarded extra arguments, and tool declarations. It had no test coverage at all, because it was private and nothing could reach it.This makes it package-private, following the convention five other members of the same class already use, and covers it.
The gap that mattered most: nothing verified that
buildConfigactually forwards extra arguments to the code that applies them. The existing tests for that code call it directly, so the connection between the two was never exercised.While adding the tests, three things turned out to be executed by the new tests but checked by none of them. They are now checked: the description and parameter schema on a tool declaration, and the guard that keeps a user's message from being sent as part of the system instruction.
Groundwork for native structured output on Gemini, which follows separately.
Tests
Four unit tests added to
GeminiChatModelConnectionTest. Module suite goes from 25 to 29, no failures. They run offline and need no API key.Each test was checked by breaking the production code it covers and confirming the test fails. Each break is caught by exactly one test, so a failure points at one cause.
API
No public API change.
buildConfigmoves from private to package-private, which widens it only within its own package. No signature, behaviour, or dependency change.Documentation
doc-neededdoc-not-neededdoc-includedWas this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code 2.1.259 (Claude Opus 5)