You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
github.com/stretchr/testify v1.11.1 is Go's most popular testing library, providing expressive assertion functions with informative failure messages. It wraps testing.T with assert (non-fatal) and require (fatal) packages, plus mock and suite utilities.
Current Usage in gh-aw
This is a core test dependency — the project depends on it deeply and correctly.
The AGENTS.md notes this is "due to requiring extensive test refactoring across the codebase." The primary culprit is the 209 err.Error() patterns. Fixing those first would unblock enabling testifylint as a preventive linter going forward.
📐 Best Practice Alignment
require.Nil on *ValidationError — already correct
5 instances in internal/config/rules/rules_test.go use require.Nil(t, err, ...) where err is *ValidationError (a custom struct pointer, not the error interface). This is intentionally correct — require.NoError only accepts the error interface. No action needed.
Length comparison clarity
A few spots use assert.Equal(t, len(x), len(y)) — both sides are dynamic. When one side is the expected value (a literal or defined constant), prefer assert.Len(t, collection, expectedLen) for a more informative failure message showing the actual collection contents.
🔧 General Improvements
testutil/mcptest/harness_test.go mixing raw t.Errorf with testify
This test harness file uses t.Errorf and t.Fatalf in places instead of testify's assertions, which is inconsistent with the rest of the codebase. Switching to require.Len(t, tools, 1) etc. would improve consistency and failure message quality.
Recommendations
Priority 1 (High Impact, ~209 changes): Replace assert.Contains(t, err.Error(), ...) with assert.ErrorContains(t, err, ...) across all test files. This prevents potential panics on nil errors and aligns with testify best practices.
Priority 2 (Follow-on): Re-enable testifylint in .golangci.yml after Priority 1 is done to enforce these patterns going forward.
Priority 3 (Low effort): Migrate harness_test.go raw t.Errorf calls to testify assertions.
https://github.com/stretchr/testifysearch_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".
https://github.com/golang/termsearch_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".
🐹 Go Fan Report: stretchr/testify
Module Overview
github.com/stretchr/testifyv1.11.1 is Go's most popular testing library, providing expressive assertion functions with informative failure messages. It wrapstesting.Twithassert(non-fatal) andrequire(fatal) packages, plusmockandsuiteutilities.Current Usage in gh-aw
This is a core test dependency — the project depends on it deeply and correctly.
assert.Equal,require.NoError,assert.Contains,require.NotNil,assert.True, bound asserters (assert.New,require.New)Usage Strengths ✅
requirefor critical checks that stop test executionassert.New(t)) used in ~20 test files to reduce repetitionassert.ElementsMatch,assert.JSONEq,assert.ErrorContainsseen in the codebaseResearch Findings
Best Practices
assert.ErrorContains(t, err, "substr")is the idiomatic way to check error message substrings — available since testify v1.7.0requirevsassertsplit should be: userequirewhen a nil/error result would panic subsequent assertionsassert.New(t)) reduce noise in files with many assertionstestifylintlinter can enforce many of these patterns automaticallyImprovement Opportunities
🏃 Quick Wins
Replace
assert.Contains(t, err.Error(), ...)withassert.ErrorContains209 instances across the codebase are checking error message substrings the long way:
Why this matters:
assert.ErrorContainsautomatically fails with a clear message iferrisnil— the current pattern panics onnil.Error()Most affected files:
internal/mcp/connection_test.go(~10 instances)internal/mcp/http_transport_test.go(~8 instances)internal/mcp/unmarshal_params_test.go(~6 instances)internal/mcp/marshal_helper_test.go(~4 instances)internal/mcp/http_connection_test.go(~4 instances)internal/config/,internal/server/,internal/logger/, etc.✨ Feature Opportunities
Enable
testifylintafter fixing the 209 patternsThe
.golangci.ymlhastestifylintexplicitly disabled:The AGENTS.md notes this is "due to requiring extensive test refactoring across the codebase." The primary culprit is the 209
err.Error()patterns. Fixing those first would unblock enablingtestifylintas a preventive linter going forward.📐 Best Practice Alignment
require.Nilon*ValidationError— already correct5 instances in
internal/config/rules/rules_test.gouserequire.Nil(t, err, ...)whereerris*ValidationError(a custom struct pointer, not theerrorinterface). This is intentionally correct —require.NoErroronly accepts theerrorinterface. No action needed.Length comparison clarity
A few spots use
assert.Equal(t, len(x), len(y))— both sides are dynamic. When one side is the expected value (a literal or defined constant), preferassert.Len(t, collection, expectedLen)for a more informative failure message showing the actual collection contents.🔧 General Improvements
testutil/mcptest/harness_test.gomixing rawt.Errorfwith testifyThis test harness file uses
t.Errorfandt.Fatalfin places instead of testify's assertions, which is inconsistent with the rest of the codebase. Switching torequire.Len(t, tools, 1)etc. would improve consistency and failure message quality.Recommendations
Priority 1 (High Impact, ~209 changes): Replace
assert.Contains(t, err.Error(), ...)withassert.ErrorContains(t, err, ...)across all test files. This prevents potential panics on nil errors and aligns with testify best practices.Priority 2 (Follow-on): Re-enable
testifylintin.golangci.ymlafter Priority 1 is done to enforce these patterns going forward.Priority 3 (Low effort): Migrate
harness_test.gorawt.Errorfcalls to testify assertions.Next Steps
assert.Contains(t, err.Error(), ...)→assert.ErrorContains(t, err, ...)(sed/gorename script)require.Contains(t, err.Error(), ...)→require.ErrorContains(t, err, ...)testifylintin.golangci.ymltestutil/mcptest/harness_test.goto use testify consistentlyGenerated by Go Fan 🐹
Module analysis saved to session state
Run: §23582738890
Note
🔒 Integrity filter blocked 5 items
The following items were blocked because they don't meet the GitHub integrity level.
search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".To allow these resources, lower
min-integrityin your GitHub frontmatter: