From 40a5de55c35d6481fd538f4c5205e47c201e3289 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Mon, 6 Jan 2025 21:55:00 +0100 Subject: Add tests for the archivers --- src/archiver/raw.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/archiver/raw.rs') 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"); + } +} -- cgit