From 20f455884c1e5b9640c7ecdf47532a8a41cac004 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 12 May 2025 16:40:04 -0300 Subject: [PATCH] test: add test for unknown compression handling and fix whitespace --- src/tests.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 7d5e514..d5053b3 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -232,6 +232,12 @@ mod tests { // Set the data directory for this test let env = format!("KEEP_DIR={} cargo run -- --verbose", data_dir.display()); + // Test with no compression + let cmd = format!("echo {} | {} -c unknown unknown", INPUT_A, env); + println!("RUNNING: {}", cmd); + let output = run_sh(cmd.as_str()); + assert!(!output.status.success(), "Command succeeded when it should have failed: {} {}", cmd, output.status); + // Test with no compression let cmd = format!("echo {} | {} -c none none", INPUT_A, env); println!("RUNNING: {}", cmd); @@ -258,7 +264,7 @@ mod tests { assert!(output.status.success(), "Command failed: {} {}", cmd, output.status); let output_str = String::from_utf8_lossy(&output.stdout).to_string(); assert!(output_str.contains(INPUT_A), "Command output does not contain expected string. Command: {} Output: {} Expected: \"{}\"", cmd, output_str, INPUT_A); - + // Test with gzip compression let cmd = format!("echo {} | {} -c gzip gzip", INPUT_A, env); @@ -272,6 +278,7 @@ mod tests { assert!(output.status.success(), "Command failed: {} {}", cmd, output.status); let output_str = String::from_utf8_lossy(&output.stdout).to_string(); assert!(output_str.contains(INPUT_A), "Command output does not contain expected string. Command: {} Output: {} Expected: \"{}\"", cmd, output_str, INPUT_A); + // Test with bzip2 compression let cmd = format!("echo {} | {} -c bzip2 bzip2", INPUT_A, env); @@ -285,17 +292,6 @@ mod tests { assert!(output.status.success(), "Command failed: {} {}", cmd, output.status); let output_str = String::from_utf8_lossy(&output.stdout).to_string(); assert!(output_str.contains(INPUT_A), "Command output does not contain expected string. Command: {} Output: {} Expected: \"{}\"", cmd, output_str, INPUT_A); - - - // Verify all items were created - let cmd = format!("{} --list", env); - let output = run_sh(cmd.as_str()); - assert!(output.status.success(), "Command failed: {}", cmd); - let output_str = String::from_utf8_lossy(&output.stdout).to_string(); - assert!(output_str.contains("none"), "Command output does not contain expected string. Command: {} Output: {}", cmd, output_str); - assert!(output_str.contains("lz4"), "Command output does not contain expected string. Command: {} Output: {}", cmd, output_str); - assert!(output_str.contains("gzip"), "Command output does not contain expected string. Command: {} Output: {}", cmd, output_str); - assert!(output_str.contains("bzip2"), "Command output does not contain expected string. Command: {} Output: {}", cmd, output_str); }); } }