|
|
|
@ -41,10 +41,10 @@ pub fn entry(basedir: &str, filter: impl Fn(&Path) -> bool, name: &str) -> Optio
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Some(Entry::new(
|
|
|
|
|
path.clone(),
|
|
|
|
|
path.file_name().expect("Failed to read file name").to_os_string(),
|
|
|
|
|
basepath
|
|
|
|
|
))
|
|
|
|
|
path.clone(),
|
|
|
|
|
path.file_name().expect("Failed to read file name").to_os_string(),
|
|
|
|
|
basepath
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Loads entire database from folder
|
|
|
|
@ -68,8 +68,8 @@ pub fn from(path_name: &str, filter: impl Fn(&Path) -> bool) -> Result<Vec<Entry
|
|
|
|
|
entry.clone(),
|
|
|
|
|
entry.file_name().expect("Failed to read file name").to_os_string(),
|
|
|
|
|
path.clone()
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -142,3 +142,26 @@ pub fn is_executable(path: &Path) -> bool {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn can_load_db() {
|
|
|
|
|
let base_dir = "tests/success";
|
|
|
|
|
let entries = from(base_dir, is_executable).expect("Could not load db");
|
|
|
|
|
let entries_names: Vec<String> = entries.iter().map(|x| x.name.clone().into_string().unwrap()).collect();
|
|
|
|
|
|
|
|
|
|
let expected: Vec<String> = vec!("task", "symlink", "no_source").iter().map(|x| x.to_string()).collect();
|
|
|
|
|
|
|
|
|
|
assert_eq!(expected.len(), entries_names.len());
|
|
|
|
|
|
|
|
|
|
for entry in expected {
|
|
|
|
|
if !entries_names.contains(&entry.to_string()) {
|
|
|
|
|
panic!("Could not find {}", &entry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|