🎨 style(eol_action): fix clippy warnings and improve Copy trait usage

This commit is contained in:
Jeremiah Russell
2025-10-20 13:56:31 +01:00
committed by Jeremiah Russell
parent ce9928aa22
commit a8a79f92ec

View File

@@ -293,13 +293,13 @@ mod tests {
} }
#[test] #[test]
fn test_clone_and_equality() { fn test_copy_and_equality() {
let trash1 = EolAction::Trash; let trash1 = EolAction::Trash;
let trash2 = trash1.clone(); let trash2 = trash1; // Copy semantics
assert_eq!(trash1, trash2); assert_eq!(trash1, trash2);
let delete1 = EolAction::Delete; let delete1 = EolAction::Delete;
let delete2 = delete1.clone(); let delete2 = delete1; // Copy semantics
assert_eq!(delete1, delete2); assert_eq!(delete1, delete2);
assert_ne!(trash1, delete1); assert_ne!(trash1, delete1);
@@ -436,9 +436,19 @@ mod tests {
#[test] #[test]
fn test_safety_properties() { fn test_safety_properties() {
// Verify safety properties are as expected // Verify safety properties are as expected
assert!(EolAction::Trash.is_reversible(), "Trash should be reversible for safety"); assert!(
assert!(!EolAction::Delete.is_reversible(), "Delete should be irreversible"); EolAction::Trash.is_reversible(),
assert_eq!(EolAction::default(), EolAction::Trash, "Default should be the safer option"); "Trash should be reversible for safety"
);
assert!(
!EolAction::Delete.is_reversible(),
"Delete should be irreversible"
);
assert_eq!(
EolAction::default(),
EolAction::Trash,
"Default should be the safer option"
);
} }
#[test] #[test]
@@ -458,7 +468,11 @@ mod tests {
]; ];
for (input, expected) in test_cases { for (input, expected) in test_cases {
assert_eq!(EolAction::parse(input), expected, "Failed for input: '{}'", input); assert_eq!(
EolAction::parse(input),
expected,
"Failed for input: '{input}'"
);
} }
} }
@@ -478,14 +492,14 @@ mod tests {
// Logging/display scenario // Logging/display scenario
let action = EolAction::Delete; let action = EolAction::Delete;
let log_message = format!("Executing {} action", action); let log_message = format!("Executing {action} action");
assert_eq!(log_message, "Executing delete action"); assert_eq!(log_message, "Executing delete action");
// Safety check scenario // Safety check scenario
let dangerous_action = EolAction::Delete; let dangerous_action = EolAction::Delete;
if !dangerous_action.is_reversible() { if !dangerous_action.is_reversible() {
// This would prompt user confirmation in real usage // This would prompt user confirmation in real usage
assert!(true, "Safety check working"); // Test that we can detect dangerous actions
} }
} }
@@ -495,7 +509,7 @@ mod tests {
fn parse_with_error(input: &str) -> Result<EolAction, String> { fn parse_with_error(input: &str) -> Result<EolAction, String> {
EolAction::parse(input) EolAction::parse(input)
.ok_or_else(|| format!("Invalid action: '{}'. Valid options: trash, delete", input)) .ok_or_else(|| format!("Invalid action: '{input}'. Valid options: trash, delete"))
} }
// Valid cases // Valid cases