resource: fix resource manager tests

A test was failing since 'watch_image' was deleting the file and recreating it while the other test was running
This commit is contained in:
SeanOMik 2024-02-18 23:41:53 -05:00
parent e6c9e0725c
commit 639ec0ee42
Signed by: SeanOMik
GPG Key ID: FEC9E2FC15235964
1 changed files with 5 additions and 4 deletions

View File

@ -237,6 +237,7 @@ impl ResourceManager {
let path = resource.path();
if let Some(loader) = self.loaders.iter()
.find(|l| l.does_support_file(&path)) {
println!("got loader");
let loader = Arc::clone(loader); // stop borrowing from self
let loaded = loader.load(self, &path)?;
let loaded = loaded.as_arc_any();
@ -325,6 +326,7 @@ mod tests {
let img = res.try_data_ref();
img.unwrap();
println!("Path = {}", res.path());
man.reload(res.clone()).unwrap();
assert_eq!(res.version(), 1);
@ -334,8 +336,9 @@ mod tests {
#[test]
fn watch_image() {
let image_path = get_image("squiggles.png");
let image_bytes = std::fs::read(&image_path).unwrap();
let orig_path = get_image("squiggles.png");
let image_path = get_image("squiggles_test.png");
std::fs::copy(orig_path, &image_path).unwrap();
let mut man = ResourceManager::new();
let res = man.request::<Texture>(&image_path).unwrap();
@ -350,8 +353,6 @@ mod tests {
let event = recv.recv().unwrap();
let event = event.unwrap();
std::fs::write(image_path, image_bytes).unwrap();
assert!(event.iter().any(|ev| ev.kind.is_remove() || ev.kind.is_modify()));
}
}