Adds scanner auto-trigger test

This commit is contained in:
Antoine Gersant 2024-10-12 16:23:31 -07:00
parent ea75497bf1
commit d1d12aecc5

View file

@ -491,6 +491,9 @@ fn get_date_created<P: AsRef<Path>>(path: P) -> Option<i64> {
mod test {
use std::path::PathBuf;
use crate::app::test::{self};
use crate::test_name;
use super::*;
#[tokio::test]
@ -562,4 +565,30 @@ mod test {
.any(|s| s.artwork.as_ref() == Some(&artwork_path));
}
}
#[tokio::test]
async fn scanner_reacts_to_config_changes() {
let ctx = test::ContextBuilder::new(test_name!()).build().await;
assert!(ctx.index_manager.is_index_empty().await);
ctx.config_manager
.set_mounts(vec![config::storage::MountDir {
source: ["test-data", "small-collection"].iter().collect(),
name: "root".to_owned(),
}])
.await
.unwrap();
tokio::time::timeout(Duration::from_secs(10), async {
loop {
tokio::time::sleep(Duration::from_millis(100)).await;
if !ctx.index_manager.is_index_empty().await {
break;
}
}
})
.await
.expect("Index did not populate");
}
}