diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-06 21:55:00 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-06 21:55:00 +0100 |
| commit | 40a5de55c35d6481fd538f4c5205e47c201e3289 (patch) | |
| tree | 6aa5ec9926460f26aba621e64047a44e70fd94ef /src/archiver/raw.rs | |
| parent | 440adc8c924f451936c7f5f2fa2dcd97fffb5573 (diff) | |
Add tests for the archivers
Diffstat (limited to 'src/archiver/raw.rs')
| -rw-r--r-- | src/archiver/raw.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/archiver/raw.rs b/src/archiver/raw.rs index ce7ecb7..8641177 100644 --- a/src/archiver/raw.rs +++ b/src/archiver/raw.rs @@ -9,3 +9,42 @@ pub fn archive(archive_directory: &Path, _: &Path, target: &Path, _: &Context) - } Ok(()) } + +#[cfg(test)] +mod tests { + use std::collections::HashMap; + use std::fs::create_dir_all; + + use super::*; + use crate::template::Value; + + use test_utilities::*; + + #[test] + fn test_copies_files() { + let test_dir = setup_test_dir(); + let archive_dir = test_dir.join("archive"); + let output_dir = test_dir.join("output"); + create_dir_all(&archive_dir).expect("Could not create archive test directory"); + create_dir_all(&output_dir).expect("Could not create output test directory"); + + create_test_file(&archive_dir.join("🤠"), "beep boop boop beep"); + + let context: Context = HashMap::new(); + + archive(&archive_dir, &test_dir, &output_dir, &context).expect("Archive failed"); + + assert_file_contents(&output_dir.join("🤠"), "beep boop boop beep"); + } + + #[test] + fn test_ignores_if_no_archive() { + let test_dir = setup_test_dir(); + let archive_dir = test_dir.join("archive"); + let output_dir = test_dir.join("output"); + + let context: Context = HashMap::new(); + + archive(&archive_dir, &test_dir, &output_dir, &context).expect("Archive failed"); + } +} |