Skip to content

Conversation

@ncode
Copy link
Owner

@ncode ncode commented Sep 6, 2025

This pull request refactors the error handling in the cleanup and run commands to use Cobra's recommended RunE pattern, improving testability and reliability. Instead of directly exiting the process on errors, the commands now return errors, allowing for better error propagation and handling in tests and higher-level code. The corresponding test files have also been updated to use the new RunE handlers and include additional test coverage for error cases.

Command error handling improvements:

  • Changed cleanupCmd and runCmd from using Run to RunE, replacing direct calls to os.Exit(1) with returning errors for better error propagation and testability. (cmd/cleanup.go, cmd/run.go) [1] [2]
  • Updated error handling in both commands to log errors and return them, including more descriptive error messages for configuration and flag parsing failures. (cmd/cleanup.go, cmd/run.go) [1] [2] [3]
  • Added missing import of fmt required for error formatting. (cmd/cleanup.go, cmd/run.go) [1] [2]
  • Ensured both commands return nil on successful completion. (cmd/cleanup.go, cmd/run.go) [1] [2]

Test updates and coverage:

  • Updated all test command definitions to use the new RunE handlers instead of Run, ensuring tests work with the new error handling approach. (cmd/cleanup_test.go, cmd/run_test.go) [1] [2] [3]
  • Added a new test case to check for invalid interval format handling in the run command. (cmd/run_test.go)…testable

@codecov
Copy link

codecov bot commented Sep 6, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.91%. Comparing base (afd6207) to head (e5e8c3a).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
cmd/run.go 18.18% 8 Missing and 1 partial ⚠️
cmd/cleanup.go 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
+ Coverage   66.26%   72.91%   +6.65%     
==========================================
  Files           7        7              
  Lines         415      432      +17     
==========================================
+ Hits          275      315      +40     
+ Misses        134      104      -30     
- Partials        6       13       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ncode ncode merged commit 9146ff3 into main Sep 6, 2025
4 of 5 checks passed
@ncode ncode deleted the juliano/tests branch September 6, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant