|
|
@ -18,9 +18,25 @@ impl Builtin for Cd { |
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cd_current() {
|
|
|
|
assert_eq!(Cd.execute(vec![".".to_string()]), Ok(()))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cd_not_existent() {
|
|
|
|
// find a path which does not exists
|
|
|
|
let mut path = Path::new("test").to_path_buf();
|
|
|
|
while path.exists() {
|
|
|
|
path.set_file_name(format!(
|
|
|
|
"{}test",
|
|
|
|
path.file_name().unwrap_or_default().to_string_lossy()
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
// No such file or directory (os error 2)
|
|
|
|
assert_ne!(Cd.execute(vec![path.to_string_lossy().to_string()]), Ok(()))
|
|
|
|
}
|
|
|
|
}
|