diff --git a/resources/tests/valid_boot/ffxivboot.ver b/resources/tests/valid_boot/ffxivboot.ver new file mode 100644 index 0000000..5768481 --- /dev/null +++ b/resources/tests/valid_boot/ffxivboot.ver @@ -0,0 +1 @@ +2012.01.01.0000.0000 \ No newline at end of file diff --git a/src/bootdata.rs b/src/bootdata.rs index 8854763..4b304ba 100755 --- a/src/bootdata.rs +++ b/src/bootdata.rs @@ -4,6 +4,7 @@ use std::fs; use std::path::PathBuf; use tracing::warn; +use crate::blowfish::Blowfish; use crate::patch::{apply_patch, PatchError}; @@ -56,3 +57,26 @@ impl BootData { true } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_valid_boot_dir() { + let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + d.push("resources/tests"); + d.push("valid_boot"); + + assert!(BootData::from_existing(d.as_path().to_str().unwrap()).is_some()); + } + + #[test] + fn test_invalid_boot_dir() { + let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + d.push("resources/tests"); + d.push("invalid_boot"); // intentionally missing so it doesn't have a .ver + + assert!(BootData::from_existing(d.as_path().to_str().unwrap()).is_none()); + } +}