this repo has no description
0
fork

Configure Feed

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

at f26a525327ea65cc8a0ba85bb6825e4691c3f435 70 lines 2.0 kB view raw
1use assert_cmd::prelude::*; 2use assert_fs::prelude::*; 3use predicates::prelude::*; 4use std::process::Command; 5 6mod common; 7use common::*; 8 9/// Roundtrip helper: compress two files into `archive.<ext>` and extract into 10/// a fresh directory, asserting that the original files come back identical. 11fn shortcut_roundtrip(ext: &str) -> Result<(), Box<dyn std::error::Error>> { 12 let file = create_test_file("test.txt", "garbage data for testing")?; 13 let file2 = create_test_file("test2.txt", "more garbage data for testing")?; 14 let working_dir = create_working_dir()?; 15 let archive_name = format!("archive.{ext}"); 16 let archive = working_dir.child(&archive_name); 17 archive.assert(predicate::path::missing()); 18 19 let mut compress = Command::cargo_bin("cmprss")?; 20 compress 21 .current_dir(&working_dir) 22 .arg("--ignore-pipes") 23 .arg(file.path()) 24 .arg(file2.path()) 25 .arg(&archive_name); 26 compress.assert().success(); 27 archive.assert(predicate::path::is_file()); 28 29 let extract_dir = create_working_dir()?; 30 let mut extract = Command::cargo_bin("cmprss")?; 31 extract 32 .current_dir(&extract_dir) 33 .arg("--ignore-pipes") 34 .arg(archive.path()); 35 extract.assert().success(); 36 37 assert_files_equal(file.path(), &extract_dir.child("test.txt")); 38 assert_files_equal(file2.path(), &extract_dir.child("test2.txt")); 39 40 Ok(()) 41} 42 43mod shortcuts { 44 use super::*; 45 46 #[test] 47 fn tgz() -> Result<(), Box<dyn std::error::Error>> { 48 shortcut_roundtrip("tgz") 49 } 50 51 #[test] 52 fn tbz() -> Result<(), Box<dyn std::error::Error>> { 53 shortcut_roundtrip("tbz") 54 } 55 56 #[test] 57 fn tbz2() -> Result<(), Box<dyn std::error::Error>> { 58 shortcut_roundtrip("tbz2") 59 } 60 61 #[test] 62 fn txz() -> Result<(), Box<dyn std::error::Error>> { 63 shortcut_roundtrip("txz") 64 } 65 66 #[test] 67 fn tzst() -> Result<(), Box<dyn std::error::Error>> { 68 shortcut_roundtrip("tzst") 69 } 70}