Skip to content

Conversation

@ncode
Copy link
Owner

@ncode ncode commented Feb 7, 2026

This pull request introduces enhanced error handling for command execution, adds extensive unit tests for critical functions, and improves testability by allowing dependency injection in the SSH connection logic. The most important changes are grouped below by theme.

Error handling improvements:

  • Refactored cmd/root.go to use RunE for the root command, returning errors instead of calling os.Exit, and updated the Execute function to return errors. This allows errors to be handled gracefully and improves testability. [1] [2] [3] [4] [5] [6]
  • Updated main.go to handle errors from cmd.Execute() by printing the error and exiting with a non-zero status.

Test coverage additions:

  • Added new unit tests for root command error handling and argument parsing in cmd/root_test.go.
  • Introduced tests for port parsing and validation logic in cmd/hosts_test.go.
  • Added comprehensive tests for host list and model behavior in internal/shell/model_test.go, as well as for shell view rendering in internal/shell/view_test.go. [1] [2]
  • Added tests for SSH connection logic, including worker and broker dispatch, and for emitting system events in internal/sshConn/message_test.go and internal/sshConn/output_test.go. [1] [2] [3]
  • Added tests for host list state and address resolution in internal/sshConn/ssh_test.go.

Testability enhancements:

  • Refactored internal/sshConn/message.go to allow injection of connection, session, and worker functions, making it easier to stub dependencies in tests. [1] [2] [3] [4]

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 78.26087% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.58%. Comparing base (f1d6f85) to head (e9d8da4).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
cmd/root.go 70.58% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master       #8       +/-   ##
===========================================
+ Coverage   50.62%   64.58%   +13.95%     
===========================================
  Files          18       18               
  Lines        1193     1200        +7     
===========================================
+ Hits          604      775      +171     
+ Misses        509      316      -193     
- Partials       80      109       +29     

☔ 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 e3315c2 into master Feb 7, 2026
2 checks passed
@ncode ncode deleted the juliano/tests branch February 7, 2026 20:53
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.

2 participants