]> git.r.bdr.sh - rbdr/blog/blame - src/archiver/raw.rs
Address more of the formatter comments
[rbdr/blog] / src / archiver / raw.rs
CommitLineData
b17907fa 1use crate::template::Context;
6352ebb0 2use crate::utils::recursively_copy;
d7fef30a
RBR
3use std::io::Result;
4use std::path::Path;
6352ebb0 5
b17907fa 6pub fn archive(archive_directory: &Path, _: &Path, target: &Path, _: &Context) -> Result<()> {
6352ebb0
RBR
7 if archive_directory.exists() {
8 return recursively_copy(archive_directory, target);
9 }
10 Ok(())
11}
40a5de55
RBR
12
13#[cfg(test)]
14mod tests {
15 use std::collections::HashMap;
16 use std::fs::create_dir_all;
17
18 use super::*;
40a5de55
RBR
19
20 use test_utilities::*;
21
22 #[test]
23 fn test_copies_files() {
24 let test_dir = setup_test_dir();
25 let archive_dir = test_dir.join("archive");
26 let output_dir = test_dir.join("output");
27 create_dir_all(&archive_dir).expect("Could not create archive test directory");
28 create_dir_all(&output_dir).expect("Could not create output test directory");
29
30 create_test_file(&archive_dir.join("🤠"), "beep boop boop beep");
31
32 let context: Context = HashMap::new();
33
34 archive(&archive_dir, &test_dir, &output_dir, &context).expect("Archive failed");
35
36 assert_file_contents(&output_dir.join("🤠"), "beep boop boop beep");
37 }
38
39 #[test]
40 fn test_ignores_if_no_archive() {
41 let test_dir = setup_test_dir();
42 let archive_dir = test_dir.join("archive");
43 let output_dir = test_dir.join("output");
44
45 let context: Context = HashMap::new();
46
47 archive(&archive_dir, &test_dir, &output_dir, &context).expect("Archive failed");
48 }
49}