Skip to content

[integrations][gemini] Cover buildConfig with unit tests - #1096

Open
weiqingy wants to merge 1 commit into
apache:mainfrom
weiqingy:280-pr6a-buildconfig-coverage
Open

[integrations][gemini] Cover buildConfig with unit tests#1096
weiqingy wants to merge 1 commit into
apache:mainfrom
weiqingy:280-pr6a-buildconfig-coverage

Conversation

@weiqingy

@weiqingy weiqingy commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Linked issue: #280

Purpose of change

GeminiChatModelConnection.buildConfig assembles 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 buildConfig actually 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. buildConfig moves from private to package-private, which widens it only within its own package. No signature, behaviour, or dependency change.

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • No

Generated-by: Claude Code 2.1.259 (Claude Opus 5)

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)
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue. labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.4.0 priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant