archive(&test_dir, &template_dir, &output_dir, &context).expect("Archive failed");
assert_file_contents(&output_dir.join("index.gmi"), "Simple things");
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = archive(&test_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = archive(&test_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
}
archive(&test_dir, &template_dir, &output_dir, &context).expect("Archive failed");
assert_file_contents(&output_dir.join("index.gph"), "Simple things");
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = archive(&test_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = archive(&test_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
}
&output_dir.join("index.gmi"),
"1736121600001/my-very-bad-file",
);
+ cleanup_test_dir(&test_dir);
}
}
archive(&archive_dir, &test_dir, &output_dir, &context).expect("Archive failed");
assert_file_contents(&output_dir.join("🤠"), "beep boop boop beep");
+ cleanup_test_dir(&test_dir);
}
#[test]
let context: Context = HashMap::new();
archive(&archive_dir, &test_dir, &output_dir, &context).expect("Archive failed");
+ cleanup_test_dir(&test_dir);
}
}
assert_file_contains(&output_dir.join("index.html"), "<p>Contextualization</p>");
assert_file_contains(&output_dir.join("index.html"), "<p>Contexternalization</p>");
+ cleanup_test_dir(&test_dir);
}
#[test]
<p>Recontexternalization</p>
",
);
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
}
1736045200000
",
);
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &posts);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &posts);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
}
assert_file_contains(&output_dir.join("feed.xml"), "<p>Contextualization</p>");
assert_file_contains(&output_dir.join("feed.xml"), "<p>Contexternalization</p>");
+ cleanup_test_dir(&test_dir);
}
#[test]
<p>Recontexternalization</p>
",
);
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
}
generate(&static_dir, &template_dir, &output_dir, &context).expect("Generate failed");
assert_file_contents(&output_dir.join("test.jpg"), "Cool hat");
+ cleanup_test_dir(&test_dir);
}
#[test]
generate(&static_dir, &template_dir, &output_dir, &context).expect("Generate failed");
assert_file_contents(&output_dir.join("nested/test.mov"), "Cool hats, multiple.");
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &context);
assert!(result.is_ok());
+ cleanup_test_dir(&test_dir);
}
}
assert_file_contains(&output_dir.join("index.txt"), "Contextualization");
assert_file_contains(&output_dir.join("index.txt"), "Contexternalization");
+ cleanup_test_dir(&test_dir);
}
#[test]
Recontexternalization
",
);
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = generate(&static_dir, &template_dir, &output_dir, &context);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
}
assert_eq!(metadata.id, "cool");
assert_eq!(metadata.created_on, 1_736_105_008_957);
+ cleanup_test_dir(&test_dir);
}
#[test]
assert!(!test_dir.join("metadata.json").exists());
let metadata = Metadata::read_or_create(&test_dir.join("metadata.json"));
assert_eq!(metadata.created_on.to_string(), metadata.id);
+ cleanup_test_dir(&test_dir);
}
#[test]
let metadata = Metadata::read_or_create(&test_dir.join("metadata.json"));
assert_eq!(metadata.created_on.to_string(), metadata.id);
+ cleanup_test_dir(&test_dir);
}
#[test]
"file2.txt",
"I also exist now, btw",
);
+ cleanup_test_dir(&test_dir);
}
#[test]
assert_file_in_repo_with_contents(&remote_dir_as_string, "file1.txt", "I exist");
assert_file_does_not_exist(&remote_dir_as_string, "boo.txt");
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = git.sync_up(&invalid_remote, &local_dir);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
#[test]
.expect("Could not sync down from remote");
assert_file_contents(&local_dir.join("file1.txt"), "I exist, but remotely");
assert_file_contents(&local_dir.join("file2.txt"), "I also exist, but remotely");
+ cleanup_test_dir(&test_dir);
}
#[test]
.expect("Could not sync down from remote");
assert_file_contents(&local_dir.join("file1.txt"), "I exist, but remotely");
assert!(!&local_dir.join("nooo.txt").exists());
+ cleanup_test_dir(&test_dir);
}
#[test]
let result = git.sync_down(&invalid_remote, &local_dir);
assert!(result.is_err());
+ cleanup_test_dir(&test_dir);
}
}
fn sync_down(&self, remote: &str, directory: &Path) -> Result<()>;
}
-pub fn add(config_directory: &Path, remote_config: &Path, remote: &String) -> Result<()> {
+pub fn add(config_directory: &Path, remote_config: &Path, remote: &str) -> Result<()> {
create_dir_all(config_directory)?;
write(remote_config, remote)?;
Ok(())
file.read_to_string(&mut contents).ok()?;
Some(contents)
}
+
+#[cfg(test)]
+mod tests {
+ use std::fs::create_dir_all;
+ use std::path::Path;
+ use std::process::{Command, Stdio};
+
+ use super::*;
+ use crate::remote::Remote;
+
+ use test_utilities::*;
+
+ #[test]
+ fn test_adds_a_remote() {
+ let test_dir = setup_test_dir();
+ let config_dir = test_dir.join("config");
+ let remote_config = config_dir.join("remoteconfig");
+
+ assert!(!&config_dir.exists());
+ add(&config_dir, &remote_config, "whaaat").expect("Could not add a remote");
+ assert!(&config_dir.exists());
+ assert_file_contents(&remote_config, "whaaat");
+
+ cleanup_test_dir(&test_dir);
+ }
+
+ #[test]
+ fn test_removes_a_remote() {
+ let test_dir = setup_test_dir();
+ let remote_config = test_dir.join("remoteconfig");
+
+ create_test_file(&remote_config, "remote control");
+
+ assert_file_contents(&remote_config, "remote control");
+ remove(&remote_config).expect("Could not remove a remote");
+ assert!(!&remote_config.exists());
+
+ cleanup_test_dir(&test_dir);
+ }
+}
assert_file_contents(&target_dir.join("nested/.hidden"), "I am not here?");
assert_file_contents(&target_dir.join(".hidden/in_plain_sight.mkv"), "Almost");
assert_file_contents(&target_dir.join(".hidden/.hidden"), "I'm double hidden");
+ cleanup_test_dir(&test_dir);
}
#[test]
recursively_copy(&source_dir, &target_dir).expect("Copy failed on empty test directory");
assert_eq!(target_dir.read_dir().unwrap().count(), 0);
+ cleanup_test_dir(&test_dir);
}
}