[test] Add tests for mcp.callSDKMethodWithReconnect and reconnectSDKTransport#6956
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[test] Add tests for mcp.callSDKMethodWithReconnect and reconnectSDKTransport#6956github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Adds 18 comprehensive tests covering: - reconnectSDKTransport: unsupported transport, connection failures, session cleanup - callSDKMethodWithReconnect: happy path, non-session errors, session-not-found reconnect logic - listResources, listPrompts, readResource, getPrompt with real sessions - ServerInfo with and without session - NewHTTPConnection server info population Coverage improvements in internal/mcp: - reconnectSDKTransport: 0% → 100% - callSDKMethodWithReconnect: 33.3% → 100% - listResources: 28.6% → 85.7% - listPrompts: 28.6% → 85.7% - readResource: 50% → 100% - getPrompt: 50% → 100% - ServerInfo: 0% → 85.7% - Package overall: 84.5% → 92.2% Co-authored-by: Copilot <223556219+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 Coverage Improvement: mcp reconnect SDK functions
Function Analyzed
internal/mcpreconnectSDKTransport,callSDKMethodWithReconnect,listResources,listPrompts,readResource,getPrompt,ServerInforeconnectSDKTransport0%,callSDKMethodWithReconnect33.3%, package overall 84.5%reconnectSDKTransport100%,callSDKMethodWithReconnect100%, package overall 92.2%Why These Functions?
reconnectSDKTransportandcallSDKMethodWithReconnectimplement the session reconnect state machine — the most complex, branchy logic ininternal/mcp— yet had 0% and 33.3% coverage respectively.listResources,listPrompts, and related methods had only their error path covered (28.6%), missing the happy path through a real SDK session entirely.Tests Added
reconnectSDKTransport— unsupported transport type (default branch)reconnectSDKTransport— Streamable connect failure (bad URL)reconnectSDKTransport— SSE connect failurereconnectSDKTransport— existing session closed before reconnectcallSDKMethodWithReconnect— happy path (no error)callSDKMethodWithReconnect— non-session-not-found error (no reconnect triggered)callSDKMethodWithReconnect— session-not-found + reconnect failscallSDKMethodWithReconnect— session-not-found + reconnect succeeds + retry succeedslistResources— with real streamable session, empty resultlistPrompts— with real streamable session, empty resultreadResource— with real streamable session (error from server expected)getPrompt— with real streamable session (error from server expected)ServerInfo— with and without sessionNewHTTPConnection— server info population from initialize responseCoverage Report
Test Execution
All 18 tests pass:
Generated by Test Coverage Improver
Next run will target the next most complex under-tested function
Warning
Firewall blocked 8 domains
The following domains were blocked by the firewall during workflow execution:
172.30.0.50go.opentelemetry.iogo.yaml.ingolang.orggoogle.golang.orggopkg.inproxy.golang.orgreleaseassets.githubusercontent.comSee Network Configuration for more information.