test: add compression tests for none, lz4, gzip, bzip2

This commit is contained in:
Andrew Phillips (aider)
2025-05-12 15:58:13 -03:00
parent d8ce6f98c6
commit 978a226b78

View File

@@ -319,4 +319,43 @@ mod tests {
assert!(output_str.is_empty(), "Command output is not empty. Command: {} Output: {}", cmd, output_str);
});
}
// Test: Compression functionality with different algorithms
#[test]
fn test_compression() {
with_temp_env(|data_dir| {
// 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 none --tag none", INPUT_A, env);
let output = run_sh(cmd.as_str());
assert!(output.status.success(), "Command failed: {}", INPUT_A);
// Test with lz4 compression
let cmd = format!("echo {} | {} -c lz4 --tag lz4", INPUT_A, env);
let output = run_sh(cmd.as_str());
assert!(output.status.success(), "Command failed: {}", INPUT_A);
// Test with gzip compression
let cmd = format!("echo {} | {} -c gzip --tag gzip", INPUT_A, env);
let output = run_sh(cmd.as_str());
assert!(output.status.success(), "Command failed: {}", INPUT_A);
// Test with bzip2 compression
let cmd = format!("echo {} | {} -c bzip2 --tag bzip2", INPUT_A, env);
let output = run_sh(cmd.as_str());
assert!(output.status.success(), "Command failed: {}", 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);
});
}
}