From b4be481a1ff87c812231819e8994c6f7788f4d9e Mon Sep 17 00:00:00 2001 From: Alessio Biancalana Date: Fri, 22 Nov 2024 19:30:04 +0100 Subject: [PATCH] Unit test archive creation --- src/tarballs.rs | 20 ++++++++++++++++++++ test/test_compression/deps/sample.txt | 1 + 2 files changed, 21 insertions(+) create mode 100644 test/test_compression/deps/sample.txt diff --git a/src/tarballs.rs b/src/tarballs.rs index 9fddc23..e559a53 100644 --- a/src/tarballs.rs +++ b/src/tarballs.rs @@ -24,3 +24,23 @@ pub fn recompress( Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + use std::fs; + + #[test] + fn recompress_successful() { + let result = recompress("vendor.tar.gz", "test/test_compression", "gz"); + fs::remove_file("vendor.tar.gz").unwrap(); + assert!(result.is_ok()); + } + + #[test] + fn recompress_error() { + let result = recompress("vendor2.tar.gz", "test/carbonara", "gz"); + fs::remove_file("vendor2.tar.gz").unwrap(); + assert!(result.is_err()); + } +} diff --git a/test/test_compression/deps/sample.txt b/test/test_compression/deps/sample.txt new file mode 100644 index 0000000..ed309ce --- /dev/null +++ b/test/test_compression/deps/sample.txt @@ -0,0 +1 @@ +sample file content