{{ message }}
[test-improver] Improve tests for mcp package#8109
Merged
lpcox merged 2 commits intoJun 26, 2026
Conversation
Add tests to reconnect_sdk_test.go covering previously untested branches: - TestBackendHasPromptsCapability: 4 sub-tests covering nil session (returns false), session with prompts capability (returns true), session without prompts capability (returns false), and session with nil capabilities (returns false). Coverage: 0% → 100%. - TestServerInfo_NilServerInfoInResult: tests the branch where the server's initialize response omits the serverInfo field, exercising the initResult.ServerInfo == nil guard. Coverage: 85.7% → 100%. Overall mcp package coverage: 91.0% → 92.3%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves unit test coverage and robustness for the internal/mcp package by adding missing edge-case tests around SDK session initialization-derived state (capabilities and serverInfo).
Changes:
- Added subtests covering
Connection.BackendHasPromptsCapability()across nil session, prompts-present, prompts-absent, and nil-capabilities scenarios. - Added a test covering the
ServerInfo()guard path when the initialize response omitsserverInfo. - Uses isolated per-subtest streamable HTTP test servers to keep scenarios deterministic.
Show a summary per file
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Test Improvements:
reconnect_sdk_test.goFile Analyzed
internal/mcp/reconnect_sdk_test.gointernal/mcpImprovements Made
1. Better Testing Patterns
BackendHasPromptsCapability2. Increased Coverage
TestBackendHasPromptsCapabilitycovering all 4 branches:false"prompts": {}in capabilities → returnstruefalsefalseTestServerInfo_NilServerInfoInResultcovering theinitResult.ServerInfo == nilguard (server omitsserverInfofrom initialize response → returns"", "")BackendHasPromptsCapabilityServerInfomcppackage total3. Cleaner & More Stable Tests
newStreamableMCPTestServer+newStreamableConnpatternst.CleanupvianewStreamableConnfor automatic connection teardowndefer srv.Close()cleanup for test serversTest Execution
All tests pass:
Why These Changes?
BackendHasPromptsCapabilitywas completely untested (0%) despite being an important guard that prevents issuingprompts/listrequests to backends that don't support them — a call that can corrupt an SDK session with an EOF response. The function has 4 distinct branches, all of which are now covered.ServerInfowas at 85.7% because theinitResult.ServerInfo == nilbranch (server doesn't returnserverInfoin its initialize response) was never exercised. The new test creates a server that omitsserverInfo, covering that final edge case.Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
index.crates.ioSee Network Configuration for more information.