[Repo Assist] test: upgrade assert.NoError to require.NoError where result is used downstream#7591
Merged
lpcox merged 1 commit intoJun 15, 2026
Conversation
In 4 test locations, assert.NoError is used immediately before code that dereferences or type-asserts the returned result. When the error check fails, this produces a cascaded failure with a confusing message about the result being nil or a zero value, rather than pointing directly at the unexpected error. Changes: - internal/difc/evaluator_test.go: use require.NoError before assert.Equal on mode (zero value when err != nil would fail with misleading diff) - internal/difc/resource_test.go:ToResult table test: use require.NoError before assert.Equal on result (nil when err != nil) - internal/difc/resource_test.go:Integration test: use require.NoError(t, err) instead of bound-asserter assert.NoError(err) before type assertion on result (nil result causes type assertion to fail as ok=false, obscuring the actual error) - internal/guard/wasm_test.go: use require.NoError before assert.NotNil and require.IsType on result (nil when err != nil) All imports already present; no new dependencies introduced. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves test failure clarity by replacing assert.NoError with require.NoError in cases where the test immediately uses the returned result, preventing cascaded follow-on failures and surfacing the real error at the point of failure.
Changes:
- Switched
assert.NoError→require.NoErrorinParseEnforcementModetests before asserting onmode. - Switched
assert.NoError→require.NoErrorinToResult()-related tests before dereferencing / type-asserting returned values. - Switched
assert.NoError→require.NoErrorin WASM path-label parsing tests before validating the returned labeled data type.
Show a summary per file
| File | Description |
|---|---|
| internal/difc/evaluator_test.go | Uses require.NoError to stop the test before asserting on a possibly zero-value mode. |
| internal/difc/resource_test.go | Uses require.NoError to stop the test before comparing / type-asserting ToResult() output. |
| internal/guard/wasm_test.go | Uses require.NoError to stop the test before validating non-nil result and expected concrete type. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
This was referenced Jun 16, 2026
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.
🤖 This PR is from Repo Assist, an automated AI assistant for this repository.
Summary
In 4 test locations across
internal/difc/andinternal/guard/,assert.NoErrorwas used immediately before code that dereferences or type-asserts the returned result. When the error check fails, this pattern produces cascaded failures with confusing messages (e.g. "expected nil, got non-nil" on a type assertion) rather than pointing directly at the unexpected error.This PR upgrades those 4 calls to
require.NoError, which stops the test on the first failure and surfaces the actual error immediately.Changes
internal/difc/evaluator_test.goassert.NoErrorrequire.NoErrorassert.Equal(t, tt.expected, mode)— mode is zero-value when err≠nilinternal/difc/resource_test.goassert.NoErrorrequire.NoErrorassert.Equal(t, tt.data, result)— result is nil when err≠nilinternal/difc/resource_test.goassert.NoError(err)(bound)require.NoError(t, err)result.([]interface{})— nil result givesok=false, obscuring the real errorinternal/guard/wasm_test.goassert.NoErrorrequire.NoErrorassert.NotNil(t, result)andrequire.IsType(...)— nil result produces misleading failureAll
requireimports were already present in the affected files. No behaviour changes in production code; no new dependencies.Test Status
The changes are mechanical (same function call, different
assert/requirepackage prefix) and carry no execution risk.Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run