mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 22:41:52 +02:00
Merge pull request #363 from twe4ked/cd-back
Implement `cd -` to return to the previous directory
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
mod helpers;
|
||||
|
||||
use helpers::Playground;
|
||||
|
||||
#[test]
|
||||
fn cd_directory_not_found() {
|
||||
let actual = nu_error!(
|
||||
@ -10,3 +12,35 @@ fn cd_directory_not_found() {
|
||||
assert!(actual.contains("dir_that_does_not_exist"));
|
||||
assert!(actual.contains("directory not found"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cd_back() {
|
||||
Playground::setup("cd_test_back", |dirs, sandbox| {
|
||||
sandbox
|
||||
.mkdir("andres")
|
||||
.mkdir("odin");
|
||||
|
||||
let odin = dirs.test().join("odin");
|
||||
let andres = dirs.test().join("andres");
|
||||
|
||||
nu!(
|
||||
cwd: dirs.test(),
|
||||
r#"
|
||||
cd odin
|
||||
mkdir a
|
||||
cd ../andres
|
||||
mkdir b
|
||||
cd -
|
||||
mkdir c
|
||||
mkdir -
|
||||
cd -
|
||||
mkdir d
|
||||
"#
|
||||
);
|
||||
|
||||
assert!(odin.join("a").exists());
|
||||
assert!(andres.join("b").exists());
|
||||
assert!(odin.join("c").exists());
|
||||
assert!(odin.join("-").join("d").exists());
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user