this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(pipeline): add tar.{bz2,zst,lzma,br,lz4,sz} roundtrip tests

+43 -6
+43 -6
tests/pipeline.rs
··· 141 141 Ok(()) 142 142 } 143 143 144 - /// Full roundtrip: directory -> tar.xz -> directory 145 - #[test] 146 - fn test_tar_xz_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 144 + /// Full roundtrip for a `tar.<codec>` compound extension using cmprss alone. 145 + /// Verifies that the extension resolver, compress pipeline, and extract 146 + /// pipeline agree for the given compound format. 147 + fn tar_pipeline_roundtrip(ext: &str) -> Result<(), Box<dyn std::error::Error>> { 147 148 let temp_dir = TempDir::new()?; 148 149 149 150 let source_dir = temp_dir.child("source"); 150 151 source_dir.create_dir_all()?; 151 152 let test_file = source_dir.child("data.txt"); 152 - test_file.write_str("tar.xz roundtrip content")?; 153 + let content = format!("{ext} roundtrip content"); 154 + test_file.write_str(&content)?; 153 155 154 - let archive = temp_dir.child("archive.tar.xz"); 156 + let archive = temp_dir.child(format!("archive.{ext}")); 155 157 Command::cargo_bin("cmprss")? 156 158 .arg("--compress") 157 159 .arg(source_dir.path()) ··· 170 172 171 173 let extracted_file = extract_dir.child("source").child("data.txt"); 172 174 extracted_file.assert(predicate::path::exists()); 173 - extracted_file.assert(predicate::str::contains("tar.xz roundtrip content")); 175 + extracted_file.assert(predicate::str::contains(content)); 174 176 175 177 Ok(()) 178 + } 179 + 180 + #[test] 181 + fn test_tar_xz_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 182 + tar_pipeline_roundtrip("tar.xz") 183 + } 184 + 185 + #[test] 186 + fn test_tar_bz2_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 187 + tar_pipeline_roundtrip("tar.bz2") 188 + } 189 + 190 + #[test] 191 + fn test_tar_zst_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 192 + tar_pipeline_roundtrip("tar.zst") 193 + } 194 + 195 + #[test] 196 + fn test_tar_lzma_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 197 + tar_pipeline_roundtrip("tar.lzma") 198 + } 199 + 200 + #[test] 201 + fn test_tar_br_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 202 + tar_pipeline_roundtrip("tar.br") 203 + } 204 + 205 + #[test] 206 + fn test_tar_lz4_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 207 + tar_pipeline_roundtrip("tar.lz4") 208 + } 209 + 210 + #[test] 211 + fn test_tar_sz_roundtrip() -> Result<(), Box<dyn std::error::Error>> { 212 + tar_pipeline_roundtrip("tar.sz") 176 213 } 177 214 178 215 // Test pipeline extraction using tar.gz with explicit compress then auto-detect extract