Skip to content

[Repo Assist] test: upgrade assert.NoError to require.NoError where result is used downstream#7591

Merged
lpcox merged 1 commit into
mainfrom
repo-assist/test-require-noop-upgrade-20260615-f1716c400552bd45
Jun 15, 2026
Merged

[Repo Assist] test: upgrade assert.NoError to require.NoError where result is used downstream#7591
lpcox merged 1 commit into
mainfrom
repo-assist/test-require-noop-upgrade-20260615-f1716c400552bd45

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR is from Repo Assist, an automated AI assistant for this repository.

Summary

In 4 test locations across internal/difc/ and internal/guard/, assert.NoError was 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

File Line Before After Why
internal/difc/evaluator_test.go 772 assert.NoError require.NoError Followed by assert.Equal(t, tt.expected, mode) — mode is zero-value when err≠nil
internal/difc/resource_test.go 104 assert.NoError require.NoError Followed by assert.Equal(t, tt.data, result) — result is nil when err≠nil
internal/difc/resource_test.go 585 assert.NoError(err) (bound) require.NoError(t, err) Followed by type assertion result.([]interface{}) — nil result gives ok=false, obscuring the real error
internal/guard/wasm_test.go 1179 assert.NoError require.NoError Followed by assert.NotNil(t, result) and require.IsType(...) — nil result produces misleading failure

All require imports were already present in the affected files. No behaviour changes in production code; no new dependencies.

Test Status

⚠️ Infrastructure note: proxy.golang.org is blocked in the CI environment for this workflow run, preventing go test from building the test binaries (module cache missing zip files). This is a pre-existing infrastructure constraint — the changes are pure test-quality improvements with no logic impact. All 4 modified lines are syntactically verified with gofmt -l (no output = correctly formatted).

The changes are mechanical (same function call, different assert/require package prefix) and carry no execution risk.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by Repo Assist · 2.2K AIC · ⊞ 50.1K ·
Comment /repo-assist to run again

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

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>
@lpcox lpcox marked this pull request as ready for review June 15, 2026 16:40
Copilot AI review requested due to automatic review settings June 15, 2026 16:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.NoErrorrequire.NoError in ParseEnforcementMode tests before asserting on mode.
  • Switched assert.NoErrorrequire.NoError in ToResult()-related tests before dereferencing / type-asserting returned values.
  • Switched assert.NoErrorrequire.NoError in 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

@lpcox lpcox merged commit 345467b into main Jun 15, 2026
24 checks passed
@lpcox lpcox deleted the repo-assist/test-require-noop-upgrade-20260615-f1716c400552bd45 branch June 15, 2026 16:42
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