1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-21 12:17:45 +00:00

Add simple tests for checking validity of BootData

This commit is contained in:
Joshua Goins 2024-04-15 18:07:06 -04:00
parent 611f048e94
commit 7a3a836566
2 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1 @@
2012.01.01.0000.0000

View file

@ -4,6 +4,7 @@
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use tracing::warn; use tracing::warn;
use crate::blowfish::Blowfish;
use crate::patch::{apply_patch, PatchError}; use crate::patch::{apply_patch, PatchError};
@ -56,3 +57,26 @@ impl BootData {
true 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());
}
}