[test-improver] Improve tests for mcpresult package#7345
Merged
Conversation
Replace manual if/t.Errorf checks with testify assert.Equal and assert.Empty, consistent with the sibling content_items_test.go in the same package. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 11, 2026
Collaborator
|
@copilot review this pr and apply any recommended changes |
Contributor
Reviewed the changes. The two modifications in
All unit tests pass with 100% coverage. No further changes needed. |
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/mcpresult/text_content_test.gointernal/mcpresultImprovements Made
Better Testing Patterns
testify/assertimport totext_content_test.goif got != tt.want { t.Errorf(...) }withassert.Equal(t, tt.want, got)in the table-driven loopif got != "" { t.Errorf(...) }withassert.Empty(t, got)inTestExtractTextContent_NilMapcontent_items_test.goin the same package (which already used testify)Why These Changes?
text_content_test.gowas the only file in themcpresultpackage not using testify, despite the package having it available (v1.11.1 ingo.mod) and the sibling filecontent_items_test.goalready usingassert/require. The manualif/t.Errorfchecks produce less readable failure output than testify's diff-aware assertions.The two specific conversions:
assert.Equal(t, tt.want, got)— produces a clear diff on failure with expected/actual values highlightedassert.Empty(t, got)— more semantically precise than comparing to"", and produces better failure messagesTest Execution
All tests pass with 100% coverage maintained:
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.