Skip to content

[test-improver] Improve tests for config package#6371

Merged
lpcox merged 1 commit into
mainfrom
test-improver/config-tool-response-filters-8bb217ccc58b1ee8
May 24, 2026
Merged

[test-improver] Improve tests for config package#6371
lpcox merged 1 commit into
mainfrom
test-improver/config-tool-response-filters-8bb217ccc58b1ee8

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Test Improvements: config_core_test.go

File Analyzed

  • Test File: internal/config/config_core_test.go
  • Package: internal/config
  • Lines Added: +51

Improvements Made

Increased Coverage

Added three test cases that exercise previously uncovered branches in validateToolResponseFilters via the TOML LoadFromFile path:

  • TestLoadFromFile_ToolResponseFilter_EmptyToolName — covers the strings.TrimSpace(toolName) == "" guard (line 127–128 of validation.go), triggered by an empty quoted TOML key ("" = ".result").
  • TestLoadFromFile_ToolResponseFilter_InvalidJqExpression — covers the gojq.Parse error path (line 136–137), triggered by a syntactically broken jq expression ("map(").
  • TestLoadFromFile_ToolResponseFilter_WhitespaceOnlyValue — covers the whitespace-only filter guard (line 131–132), triggered by a filter value consisting only of spaces.

Previous Coverage (validateToolResponseFilters): 85.7%
New Coverage (validateToolResponseFilters): 92.9%
Improvement: +7.2%
Overall config package: 95.1% → 95.3% (+0.2%)

Why These Tests Were Missing

The existing TestLoadFromFile_ToolResponseFilters only tested the happy path (valid jq filter). The error paths were tested via validateStandardServerConfig in validation_test.go, but the TOML path (LoadFromFilevalidateToolResponseFilters) had no coverage for these branches.

Test Execution

All new tests pass:

=== RUN   TestLoadFromFile_ToolResponseFilter_EmptyToolName
--- PASS: TestLoadFromFile_ToolResponseFilter_EmptyToolName (0.00s)
=== RUN   TestLoadFromFile_ToolResponseFilter_InvalidJqExpression
--- PASS: TestLoadFromFile_ToolResponseFilter_InvalidJqExpression (0.00s)
=== RUN   TestLoadFromFile_ToolResponseFilter_WhitespaceOnlyValue
--- PASS: TestLoadFromFile_ToolResponseFilter_WhitespaceOnlyValue (0.00s)
PASS
ok  	github.com/github/gh-aw-mcpg/internal/config	1.675s	coverage: 95.3% of statements

Note: TestBufferRetryLogic/module_has_no_memory in internal/guard is a pre-existing failure unrelated to these changes (nil pointer dereference in wazero wasm memory).


Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests

Generated by Test Improver · ● 4.6M ·

Add three new test cases to config_core_test.go that exercise
previously uncovered branches in validateToolResponseFilters
when called via LoadFromFile (TOML path):

- TestLoadFromFile_ToolResponseFilter_EmptyToolName: verifies that
  an empty quoted key in the tool_response_filters table returns an
  error containing 'empty tool name'.
- TestLoadFromFile_ToolResponseFilter_InvalidJqExpression: verifies
  that a syntactically invalid jq expression is rejected with an
  error containing 'invalid jq expression'.
- TestLoadFromFile_ToolResponseFilter_WhitespaceOnlyValue: verifies
  that a whitespace-only filter value is rejected with 'must not
  be empty'.

These tests bring validateToolResponseFilters coverage from 85.7%
to 92.9% and overall config package coverage from 95.1% to 95.3%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review May 24, 2026 13:50
Copilot AI review requested due to automatic review settings May 24, 2026 13:50
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 the robustness of the internal/config package’s TOML loading tests by adding negative test cases that exercise previously uncovered validation branches for tool_response_filters when configs are loaded via LoadFromFile.

Changes:

  • Add a TOML test case that ensures an empty quoted tool name key is rejected.
  • Add a TOML test case that ensures syntactically invalid jq expressions are rejected.
  • Add a TOML test case that ensures whitespace-only filter values are rejected as empty.
Show a summary per file
File Description
internal/config/config_core_test.go Adds new LoadFromFile-path tests covering validateToolResponseFilters error branches for empty tool names, invalid jq, and empty/whitespace filters.

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: 0

@lpcox lpcox merged commit cedfcee into main May 24, 2026
23 checks passed
@lpcox lpcox deleted the test-improver/config-tool-response-filters-8bb217ccc58b1ee8 branch May 24, 2026 23:02
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