brev-cli icon indicating copy to clipboard operation
brev-cli copied to clipboard

Fix: Improve error handling for missing SSH client and add unit tests for `shell` command

Open asideofcode-dev opened this issue 1 year ago • 0 comments

Summary

NOTE: The first 3 commits are based off the preceding PR https://github.com/brevdev/brev-cli/pull/198.

Resolves #185

This PR addresses the issue where running the brev shell command in a Docker environment without an installed SSH client would cause a panic. Additionally, it improves the error handling when the specified workspace cannot be found.

Key changes

  1. SSH Client Check:

    • Added a check to ensure that the SSH client is installed and available in the system's PATH before attempting to establish a connection. If the SSH client is not found, a clear and actionable error message is returned.
  2. Unit Tests:

    • Added unit tests to verify the behavior when the SSH client is not installed, ensuring that the error is properly caught and reported.
    • Added a test case to validate that an appropriate error is raised when the workspace is not found.
  3. Code Cleanup:

    • Performed minor formatting improvements and removed unnecessary whitespace for cleaner code.

Impact

  • Users running brev shell in environments without an SSH client will now receive a clear error message guiding them to install the required software.
  • Ensures robustness in handling edge cases where the specified workspace cannot be found.

asideofcode-dev avatar Aug 15 '24 11:08 asideofcode-dev