diff --git a/cli/src/cmd_auth.rs b/cli/src/cmd_auth.rs index 57a2f91f..fb04df48 100644 --- a/cli/src/cmd_auth.rs +++ b/cli/src/cmd_auth.rs @@ -486,6 +486,27 @@ impl CmdAuthStatus { #[cfg(test)] mod tests { + #[test] + fn test_cmd_auth_login() { + use assert_cmd::Command; + use predicates::str; + + let bad_url = "sys.oxide.invalid"; + + // Validate connection error details are printed + Command::cargo_bin("oxide") + .unwrap() + .arg("auth") + .arg("login") + .arg("--host") + .arg(bad_url) + .assert() + .failure() + .stderr(str::starts_with(format!( + "Request failed: error sending request for url (https://{bad_url}/device/auth):" + ))); + } + #[test] fn test_parse_host() { use super::parse_host; diff --git a/cli/src/main.rs b/cli/src/main.rs index 9e70b5b8..91093ef0 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -101,7 +101,8 @@ async fn main() { .await .unwrap(); if let Err(e) = result { - eprintln!("{e}"); + let src = e.source().map(|s| format!(": {s}")).unwrap_or_default(); + eprintln!("{e}{src}"); std::process::exit(1) } }