[test] Add tests for mcpresult.ExtractTextContent - #7060
Conversation
Adds comprehensive table-driven tests for ExtractTextContent in the
internal/mcpresult package. Coverage goes from 0% to 100%.
Tests cover all branches in the function:
- Missing/nil content key
- Unsupported content types (string, int, map, bool)
- Empty []interface{} and []map[string]interface{} slices
- Item type filtering: text/empty (kept), image/audio/resource (skipped),
unknown types (kept per backward-compat comment)
- Non-map items in []interface{} (skipped)
- Empty or non-string text values (skipped)
- []map[string]interface{} typed slice path
- Multi-item concatenation and mixed-type scenarios
- Nil map input, unicode content, whitespace-only text
Note: tests use only the standard library testing package; testify is
unavailable in the network-restricted CI environment.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot fix the failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/27029273303/job/79888506961?pr=7060 |
There was a problem hiding this comment.
Pull request overview
Adds a comprehensive table-driven test suite for internal/mcpresult.ExtractTextContent, improving confidence in the function’s branching behavior across supported content shapes and edge cases.
Changes:
- Added coverage for
contentbeing absent/nil, unsupported types, empty slices, and mixed item types. - Added coverage for both
[]interface{}and[]map[string]interface{}input forms (including non-map items and invalidtextfields). - Added a dedicated nil-map input test.
Show a summary per file
| File | Description |
|---|---|
| internal/mcpresult/text_content_test.go | Adds comprehensive unit tests covering all ExtractTextContent branches and edge cases. |
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
Fixed in commit |
|
@copilot fix the failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/27066749712/job/79888856571?pr=7060 |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test Coverage Improvement: ExtractTextContent
Function Analyzed
internal/mcpresultExtractTextContentWhy This Function?
ExtractTextContentwas selected because it had 0% coverage and meaningful complexity: it handles two distinct input slice types ([]interface{}vs[]map[string]interface{}), filters content items by type (text/image/audio/resource/unknown), performs type assertions on the text field, and has several skip conditions. Covering all branches requires a rich test suite.Tests Added
[]interface{}and[]map[string]interface{}contentkey and nil content value"")[]interface{}and[]map[string]interface{})"text"and""kept;"image","audio","resource"skipped; unknown types kept per backward-compat[]interface{}are skippedCoverage Report
Test Execution
All 37 sub-tests pass:
Generated by Test Coverage Improver
Next run will target the next most complex under-tested function
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
proxy.golang.orgsum.golang.orgSee Network Configuration for more information.