Skip to content

[test-improver] Improve tests for mcp pagination helpers#6922

Merged
lpcox merged 2 commits into
mainfrom
test-improver/mcp-pagination-coverage-827df6e04bc8d0d0
Jun 3, 2026
Merged

[test-improver] Improve tests for mcp pagination helpers#6922
lpcox merged 2 commits into
mainfrom
test-improver/mcp-pagination-coverage-827df6e04bc8d0d0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 3, 2026

File Analyzed

  • Test File: internal/mcp/pagination_test.go
  • Package: internal/mcp

Improvements Made

1. Increased Coverage

Three new tests added to cover previously-untested error paths in the generic helpers callParamMethod and listMCPItems:

  • TestCallParamMethod_UnmarshalError — covers the unmarshalParams error branch, reached by injecting a non-nil sdk.ClientSession{} so requireSession() passes, then passing a channel value that json.Marshal cannot encode
  • TestCallParamMethod_FnError — covers the fn(params) error return path in callParamMethod
  • TestListMCPItems_PaginateError — covers the paginateAll error propagation path in listMCPItems

Previous Coverage:

Function Before After
callParamMethod 77.8% 100.0%
listMCPItems 85.7% 100.0%
internal/mcp total 84.0% 84.5%

2. Cleaner Test Structure

  • Uses t.Run-style subtests where applicable
  • Follows existing table-driven and named-test conventions in the file
  • Uses require.Error / assert.ErrorIs for precise error assertions

Test Execution

All Go tests pass:

ok  github.com/github/gh-aw-mcpg/internal/mcp  2.3s

Why These Changes?

callParamMethod and listMCPItems are 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-value sdk.ClientSession{} pointer (sufficient to pass the nil check in requireSession) 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.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "index.crates.io"

See Network Configuration for more information.

Generated by Test Improver · sonnet46 3.8M ·

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>
@lpcox lpcox marked this pull request as ready for review June 3, 2026 00:24
Copilot AI review requested due to automatic review settings June 3, 2026 00:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in callParamMethod.
  • 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

Comment thread internal/mcp/pagination_test.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 71ebfed into main Jun 3, 2026
16 checks passed
@lpcox lpcox deleted the test-improver/mcp-pagination-coverage-827df6e04bc8d0d0 branch June 3, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants