fixing tests had to make serial to cleanup
This commit is contained in:
parent
32049aee34
commit
f9ee535d4d
11 changed files with 307 additions and 61 deletions
188
Cargo.lock
generated
188
Cargo.lock
generated
|
|
@ -239,6 +239,19 @@ dependencies = [
|
|||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "5.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"hashbrown",
|
||||
"lock_api",
|
||||
"once_cell",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "data-encoding"
|
||||
version = "2.4.0"
|
||||
|
|
@ -304,6 +317,83 @@ dependencies = [
|
|||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
|
|
@ -314,6 +404,12 @@ dependencies = [
|
|||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.2"
|
||||
|
|
@ -356,12 +452,28 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.147"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.20"
|
||||
|
|
@ -442,6 +554,29 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.4.2"
|
||||
|
|
@ -465,6 +600,18 @@ dependencies = [
|
|||
"sha2 0.10.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.27"
|
||||
|
|
@ -606,6 +753,31 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d"
|
||||
dependencies = [
|
||||
"dashmap",
|
||||
"futures",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"serial_test_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test_derive"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sevenz-rust"
|
||||
version = "0.5.2"
|
||||
|
|
@ -668,12 +840,28 @@ dependencies = [
|
|||
"rayon",
|
||||
"ring",
|
||||
"rust-lzma",
|
||||
"serial_test",
|
||||
"sevenz-rust",
|
||||
"tar",
|
||||
"unrar",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ flate2 = "1.0.27"
|
|||
rayon = "1.7.0"
|
||||
ring = "0.16.20"
|
||||
rust-lzma = "0.6.0"
|
||||
serial_test = "2.0.0"
|
||||
sevenz-rust = "0.5.2"
|
||||
tar = "0.4.40"
|
||||
unrar = "0.5.1"
|
||||
|
|
|
|||
175
src/lib/lib.rs
175
src/lib/lib.rs
|
|
@ -1,9 +1,7 @@
|
|||
use data_encoding::HEXUPPER;
|
||||
use ring::digest::{Context, Digest, SHA256};
|
||||
use std::{fs::{self, File},io::{BufReader, Read},os::unix::fs::PermissionsExt,path::Path};
|
||||
|
||||
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
pub mod extractors;
|
||||
|
||||
|
|
@ -40,31 +38,33 @@ use extractors::{
|
|||
// extract_exe
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_extract_zip() {
|
||||
let input_path = Path::new("src/test_data/test.zip");
|
||||
let output_directory = create_permanent_dir();
|
||||
|
||||
// Extract the zip file
|
||||
let result = extract_zip(input_path, &output_directory);
|
||||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
assert_eq!(checksum_01, true);
|
||||
assert_eq!(checksum_02, true);
|
||||
assert_eq!(checksum_03, true);
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_zip() {
|
||||
let input_path = Path::new("src/test_data/test.zip");
|
||||
let output_directory = create_temp_dir();
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
// Extract the zip file
|
||||
let result = extract_zip(input_path, &output_directory);
|
||||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
assert_eq!(checksum_01, true);
|
||||
assert_eq!(checksum_02, true);
|
||||
assert_eq!(checksum_03, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_rar() {
|
||||
let input_path = Path::new("src/test_data/test.rar");
|
||||
let output_directory = create_temp_dir();
|
||||
|
|
@ -72,16 +72,25 @@ fn test_extract_zip() {
|
|||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("src/test_data/checksum_02", "src/test_data/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("src/test_data/checksum_03", "src/test_data/testfile_03").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
println!["{}", checksum_01];
|
||||
assert_eq!(checksum_01, true);
|
||||
println!["{}", checksum_02];
|
||||
assert_eq!(checksum_02, true);
|
||||
println!["{}", checksum_03];
|
||||
assert_eq!(checksum_03, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_tar() {
|
||||
let input_path = Path::new("src/test_data/test.tar");
|
||||
let output_directory = create_temp_dir();
|
||||
|
|
@ -89,16 +98,25 @@ fn test_extract_zip() {
|
|||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("src/test_data/checksum_02", "src/test_data/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("src/test_data/checksum_03", "src/test_data/testfile_03").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
println!["{}", checksum_01];
|
||||
assert_eq!(checksum_01, true);
|
||||
println!["{}", checksum_02];
|
||||
assert_eq!(checksum_02, true);
|
||||
println!["{}", checksum_03];
|
||||
assert_eq!(checksum_03, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_lzma() {
|
||||
let input_path = Path::new("src/test_data/test.lzma");
|
||||
let csum_path = Path::new("src/test_data/test_csum.lzma");
|
||||
|
|
@ -109,11 +127,17 @@ fn test_extract_zip() {
|
|||
assert!(checksum.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
assert_eq!(checksum_01, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_gz() {
|
||||
let input_path = Path::new("src/test_data/test.gz");
|
||||
let csum_path = Path::new("src/test_data/test_csum.gz");
|
||||
|
|
@ -124,11 +148,17 @@ fn test_extract_zip() {
|
|||
assert!(checksum.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
assert_eq!(checksum_01, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_bz2() {
|
||||
let input_path = Path::new("src/test_data/test.bz2");
|
||||
let csum_path = Path::new("src/test_data/test_csum.bz2");
|
||||
|
|
@ -139,11 +169,17 @@ fn test_extract_zip() {
|
|||
assert!(checksum.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
assert_eq!(checksum_01, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_7z() {
|
||||
let input_path = Path::new("src/test_data/test.7z");
|
||||
let output_directory = create_temp_dir();
|
||||
|
|
@ -151,16 +187,22 @@ fn test_extract_zip() {
|
|||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("src/test_data/checksum_02", "src/test_data/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("src/test_data/checksum_03", "src/test_data/testfile_03").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
assert_eq!(checksum_01, true);
|
||||
assert_eq!(checksum_02, true);
|
||||
assert_eq!(checksum_03, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_tbz2() {
|
||||
let input_path = Path::new("src/test_data/test.tbz2");
|
||||
let output_directory = create_temp_dir();
|
||||
|
|
@ -170,16 +212,22 @@ fn test_extract_zip() {
|
|||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("src/test_data/checksum_02", "src/test_data/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("src/test_data/checksum_03", "src/test_data/testfile_03").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
assert_eq!(checksum_01, true);
|
||||
assert_eq!(checksum_02, true);
|
||||
assert_eq!(checksum_03, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_tgz() {
|
||||
let input_path = Path::new("src/test_data/test.tgz");
|
||||
let output_directory = create_temp_dir();
|
||||
|
|
@ -189,16 +237,22 @@ fn test_extract_zip() {
|
|||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("src/test_data/checksum_02", "src/test_data/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("src/test_data/checksum_03", "src/test_data/testfile_03").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
assert_eq!(checksum_01, true);
|
||||
assert_eq!(checksum_02, true);
|
||||
assert_eq!(checksum_03, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_extract_txz() {
|
||||
let input_path = Path::new("src/test_data/test.txz");
|
||||
let output_directory = create_temp_dir();
|
||||
|
|
@ -208,13 +262,18 @@ fn test_extract_zip() {
|
|||
assert!(result.is_ok());
|
||||
|
||||
// Check checksums and assert equality
|
||||
let checksum_01 = verify_checksum("src/test_data/checksum_01", "src/test_data/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("src/test_data/checksum_02", "src/test_data/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("src/test_data/checksum_03", "src/test_data/testfile_03").unwrap();
|
||||
let checksum_01 = verify_checksum("test_dir/checksum_01", "test_dir/testfile_01").unwrap();
|
||||
let checksum_02 = verify_checksum("test_dir/checksum_02", "test_dir/testfile_02").unwrap();
|
||||
let checksum_03 = verify_checksum("test_dir/checksum_03", "test_dir/testfile_03").unwrap();
|
||||
|
||||
assert_eq!(checksum_01, true);
|
||||
assert_eq!(checksum_02, true);
|
||||
assert_eq!(checksum_03, true);
|
||||
|
||||
// Delete the test directory at the end of the test
|
||||
if let Err(err) = fs::remove_dir_all(&output_directory) {
|
||||
eprintln!("Failed to delete test directory: {:?}", err);
|
||||
}
|
||||
}
|
||||
|
||||
fn verify_checksum(checksum_path: &str, testfile_path: &str) -> Result<bool, std::io::Error> {
|
||||
|
|
@ -248,22 +307,16 @@ fn test_extract_zip() {
|
|||
}
|
||||
|
||||
fn create_temp_dir() -> PathBuf {
|
||||
let mut temp_dir = std::env::temp_dir();
|
||||
temp_dir.push("test_dir");
|
||||
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");
|
||||
temp_dir
|
||||
}
|
||||
fn create_permanent_dir() -> PathBuf {
|
||||
// Specify the absolute path for the permanent directory
|
||||
let permanent_dir = Path::new("test_dir");
|
||||
// Specify the absolute path for the permanent directory
|
||||
let temp_dir = Path::new("test_dir");
|
||||
|
||||
// Create the directory if it doesn't exist
|
||||
if !temp_dir.exists() {
|
||||
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");
|
||||
}
|
||||
temp_dir.to_path_buf()
|
||||
}
|
||||
|
||||
// Create the directory if it doesn't exist
|
||||
if !permanent_dir.exists() {
|
||||
fs::create_dir_all(&permanent_dir).expect("Failed to create permanent directory");
|
||||
}
|
||||
|
||||
permanent_dir.to_path_buf()
|
||||
}
|
||||
fn sha256_digest<R: Read>(mut reader: R) -> Result<Digest, std::io::Error> {
|
||||
let mut context = Context::new(&SHA256);
|
||||
let mut buffer = [0; 1024];
|
||||
|
|
|
|||
1
src/test_data/checksum_01
Normal file
1
src/test_data/checksum_01
Normal file
|
|
@ -0,0 +1 @@
|
|||
c63a52591e30851e2dc94705902a592dea89c3134166df1c0a8979f90d9ea0a2 testfile_01
|
||||
1
src/test_data/checksum_02
Normal file
1
src/test_data/checksum_02
Normal file
|
|
@ -0,0 +1 @@
|
|||
dd5c253429a3a1a34e382ff0158555d4a573ace73c1a4fb60e5b215053d8b6ab testfile_02
|
||||
1
src/test_data/checksum_03
Normal file
1
src/test_data/checksum_03
Normal file
|
|
@ -0,0 +1 @@
|
|||
1e103ac2fc72820330a578900880744481726c7752ead976e3a30963ee4b39bc testfile_03
|
||||
BIN
src/test_data/testfile_01
Normal file
BIN
src/test_data/testfile_01
Normal file
Binary file not shown.
BIN
src/test_data/testfile_02
Normal file
BIN
src/test_data/testfile_02
Normal file
Binary file not shown.
BIN
src/test_data/testfile_03
Normal file
BIN
src/test_data/testfile_03
Normal file
Binary file not shown.
BIN
test_dir/test
Normal file
BIN
test_dir/test
Normal file
Binary file not shown.
1
test_dir/test_csum
Normal file
1
test_dir/test_csum
Normal file
|
|
@ -0,0 +1 @@
|
|||
c63a52591e30851e2dc94705902a592dea89c3134166df1c0a8979f90d9ea0a2 testfile_01
|
||||
Loading…
Add table
Add a link
Reference in a new issue