Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions crates/cli/src/output/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,29 @@ mod tests {
assert_eq!(details.suggestion.as_deref(), Some(USAGE_SUGGESTION));
}

#[test]
fn test_error_descriptor_from_message_infers_conflict() {
let descriptor = ErrorDescriptor::from_message("Destination exists at target path");
let json = descriptor.to_json_output();

let details = json.details.expect("details should be present");
assert_eq!(details.error_type, "conflict");
assert!(!details.retryable);
assert_eq!(details.suggestion.as_deref(), Some(CONFLICT_SUGGESTION));
}

#[test]
fn test_error_descriptor_from_message_infers_retryable_network_error() {
let descriptor =
ErrorDescriptor::from_message("Service temporarily unavailable while connecting");
let json = descriptor.to_json_output();

let details = json.details.expect("details should be present");
assert_eq!(details.error_type, "network_error");
assert!(details.retryable);
assert_eq!(details.suggestion.as_deref(), Some(NETWORK_SUGGESTION));
}

#[test]
fn test_error_with_suggestion_overrides_default_hint() {
let descriptor = ErrorDescriptor::from_code(
Expand Down