pkg/cli tests: migrate assert.NoError to require.NoError for fail-fast error handling#47355
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
assert.NoError to require.NoError for fail-fast error handling
There was a problem hiding this comment.
Pull request overview
Migrates pkg/cli tests to fail fast when critical operations return errors.
Changes:
- Replaces remaining
assert.NoErrorcalls withrequire.NoError. - Adds the newly required Testify import.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/update_integration_test.go |
Makes update integration checks fail fast. |
pkg/cli/update_extension_check_test.go |
Makes backup existence validation fatal. |
pkg/cli/update_command_test.go |
Makes update command validation fatal. |
pkg/cli/trial_dry_run_test.go |
Makes successful dry-run preconditions fatal. |
pkg/cli/status_remote_test.go |
Makes remote status error validation fatal. |
pkg/cli/spec_test.go |
Makes successful API validation checks fatal. |
pkg/cli/secrets_command_test.go |
Makes command execution errors fatal. |
pkg/cli/remote_workflow_test.go |
Makes remote workflow operations fail fast. |
pkg/cli/project_command_test.go |
Makes valid argument checks fatal. |
pkg/cli/outcome_eval_test.go |
Makes endpoint validation fail fast. |
pkg/cli/mcp_server_workflow_validation_test.go |
Adds require and uses fatal validation. |
pkg/cli/logs_download_agent_outputs_test.go |
Makes artifact flattening errors fatal. |
pkg/cli/logs_artifact_set_test.go |
Makes successful set validation fatal. |
pkg/cli/list_workflows_command_test.go |
Makes workflow-listing errors fatal. |
pkg/cli/domains_command_test.go |
Makes domain command failures fatal. |
pkg/cli/copilot_billing_check_test.go |
Makes successful billing checks fatal. |
pkg/cli/completion_integration_test.go |
Makes completion-file validation fatal. |
pkg/cli/compile_safe_update_integration_test.go |
Makes compilation and file checks fatal. |
pkg/cli/compile_guard_policy_test.go |
Makes successful compilation checks fatal. |
pkg/cli/checks_command_test.go |
Makes valid argument checks fatal. |
pkg/cli/add_command_test.go |
Makes successful add operations fatal. |
pkg/cli/actions_build_command_test.go |
Makes action command errors fatal. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 22/22 changed files
- Comments generated: 0
- Review effort level: Medium
|
✅ Test Quality Sentinel completed test quality analysis. PR #47355 is purely a refactoring migration from assert.NoError to require.NoError for fail-fast error handling. No new tests were added or modified in logic — only assertion method calls were changed. Test Quality Sentinel analysis skipped as there are no new or substantively modified test functions to analyze. |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ |
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #47355 does not have the 'implementation' label and has only 50 new lines of code in business logic directories (threshold: 100). |
|
✅ PR Code Quality Reviewer completed the code quality review. |
There was a problem hiding this comment.
Clean, mechanical migration from assert.NoError to require.NoError across CLI test files. This is the correct pattern — fail-fast error handling prevents cascading failures and makes test output easier to diagnose. No issues found.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 15.6 AIC · ⌖ 4.45 AIC · ⊞ 5K
There was a problem hiding this comment.
Skills-Based Review
Applied /tdd — this is a clean, correct mechanical migration.
Positive Highlights
- All assert.NoError on critical error paths correctly replaced with require.NoError for fail-fast semantics
- Scope is precisely limited to test files — no production code touched
- Import additions are minimal and correct
- Non-NoError assertions intentionally left unchanged — appropriate
No issues found. The migration is complete and consistent across all 22 changed files.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 18 AIC · ⌖ 4.48 AIC · ⊞ 6.7K
Comment /matt to run again
🧪 Test Quality Sentinel Reporti️ Refactoring: No New Test Coverage
📊 Analysis SummaryChange Classification:
Imports Added:
Assessment: Verdict
|
There was a problem hiding this comment.
REQUEST_CHANGES — one migration artifact left behind
The mechanical assert.NoError → require.NoError migration is correct and well-scoped, but it introduced one piece of dead code that must be fixed before merge.
Blocking finding
pkg/cli/completion_integration_test.go line 158: The if err == nil guard that wraps the ReadFile block was necessary when line 155 used assert.NoError (execution continued on failure). Now that line 155 uses require.NoError, the test aborts immediately on a stat failure — the guard is always true when reached and should be removed.
No other issues found. The migration is otherwise correct across all 22 files.
🔎 Code quality review by PR Code Quality Reviewer · sonnet46 58.8 AIC · ⌖ 4.66 AIC · ⊞ 5.7K
Comment /review to run again
| require.NoError(t, err, "Completion file should exist at: %s", completionPath) | ||
|
|
||
| // Verify the file contains bash completion content | ||
| if err == nil { |
There was a problem hiding this comment.
Dead code: if err == nil guard is now always true after migrating to require.NoError.
💡 Suggested fix
Before the migration, assert.NoError on line 155 let the test continue even when os.Stat failed, so the if err == nil guard was meaningful — it protected the ReadFile call from panicking.
After replacing it with require.NoError, the test halts immediately on a stat failure. The guard is therefore dead code: it is always true when execution reaches line 158. It should be removed to avoid misleading future readers.
// After the migration, guard is redundant — remove it:
_, err = os.Stat(completionPath)
require.NoError(t, err, "Completion file should exist at: %s", completionPath)
content, readErr := os.ReadFile(completionPath)
require.NoError(t, readErr, "Should be able to read completion file")
assert.Contains(t, string(content), "# bash completion")
assert.Contains(t, string(content), "__start_gh")This is a direct consequence of the assert → require change on line 155; the guard must be cleaned up alongside it.
|
@copilot run pr-reviewer skill |
Ran a PR review on the current diff and a targeted |
|
🎉 This pull request is included in a new release. Release: |
pkg/clitests hadassert.NoErrorchecks on critical error paths, allowing execution to continue after setup/command failures and creating cascading noise. This change applies a mechanical fail-fast migration torequire.NoErroracross the suite.Mechanical refactor
assert.NoError(t, err, ...)occurrences inpkg/cli/*_test.gowithrequire.NoError(t, err, ...).Import alignment
github.com/stretchr/testify/requirewhere newly needed (notablymcp_server_workflow_validation_test.go).NoErrorassertions unchanged.Behavioral intent