forked from forge/build.rs
Some tests
This commit is contained in:
parent
d02aca6864
commit
603f040b97
35
src/db.rs
35
src/db.rs
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "LOL sourceless task"
|
|
@ -0,0 +1 @@
|
|||
../no_source
|
|
@ -0,0 +1 @@
|
|||
../symlink
|
|
@ -0,0 +1 @@
|
|||
../symlink.source
|
|
@ -0,0 +1 @@
|
|||
../task
|
|
@ -0,0 +1 @@
|
|||
../task.source
|
|
@ -0,0 +1 @@
|
|||
task
|
|
@ -0,0 +1 @@
|
|||
task.source
|
|
@ -0,0 +1,3 @@
|
|||
#! /bin/bash
|
||||
|
||||
echo Hello
|
|
@ -0,0 +1 @@
|
|||
https://tildegit.org/southerntofu/git-build.sh
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Ce script ne devrait jamais être exécuté"
|
|
@ -0,0 +1 @@
|
|||
SDJSQKLDJQKLSDJQS
|
Loading…
Reference in New Issue