[test-improver] Improve tests for mcp pagination helpers#6922
Merged
lpcox merged 2 commits intoJun 3, 2026
Conversation
Add targeted unit tests for callParamMethod and listMCPItems error paths in pagination_test.go: - TestCallParamMethod_UnmarshalError: covers the unmarshalParams error branch when rawParams cannot be marshalled (e.g. a channel value) - TestCallParamMethod_FnError: covers the fn() error return path - TestListMCPItems_PaginateError: covers the paginateAll error path Coverage improvement: callParamMethod: 77.8% → 100.0% listMCPItems: 85.7% → 100.0% internal/mcp total: 84.0% → 84.5% Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves unit test coverage for the generic MCP pagination/helpers in internal/mcp, specifically exercising previously untested error paths to ensure failures are propagated correctly.
Changes:
- Added a test covering parameter marshaling failure in
callParamMethod(via an unmarshalable channel value). - Added a test covering propagation of handler (
fn) errors incallParamMethod. - Added a test covering pagination/fetch error propagation through
listMCPItems.
Show a summary per file
| File | Description |
|---|---|
internal/mcp/pagination_test.go |
Adds targeted tests for error branches in callParamMethod and listMCPItems to increase coverage and improve confidence in error propagation. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
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.
File Analyzed
internal/mcp/pagination_test.gointernal/mcpImprovements Made
1. Increased Coverage
Three new tests added to cover previously-untested error paths in the generic helpers
callParamMethodandlistMCPItems:TestCallParamMethod_UnmarshalError— covers theunmarshalParamserror branch, reached by injecting a non-nilsdk.ClientSession{}sorequireSession()passes, then passing a channel value thatjson.Marshalcannot encodeTestCallParamMethod_FnError— covers thefn(params)error return path incallParamMethodTestListMCPItems_PaginateError— covers thepaginateAllerror propagation path inlistMCPItemsPrevious Coverage:
callParamMethodlistMCPItemsinternal/mcptotal2. Cleaner Test Structure
t.Run-style subtests where applicablerequire.Error/assert.ErrorIsfor precise error assertionsTest Execution
All Go tests pass:
Why These Changes?
callParamMethodandlistMCPItemsare generic helpers used by all MCP list/call operations. Their error-handling branches were not directly tested — coverage came only from higher-level tests that happened to reach the happy path. The new tests exercise the error paths directly using a zero-valuesdk.ClientSession{}pointer (sufficient to pass the nil check inrequireSession) and unmarshalable inputs, making the coverage complete without requiring a real MCP server connection.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.