Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

Commit 71aea3c

Browse files
committed
fix: revert current directory after test
1 parent 5ce6c02 commit 71aea3c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

crates/cli/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,26 @@ mod tests {
6262

6363
#[tokio::test]
6464
async fn init_command_should_create_package_json() {
65+
let current_directory = env::current_dir().unwrap();
6566
let parent_folder = prepare();
6667
let cli = Cli::parse_from(["", "init"]);
6768
run_commands(cli).await.unwrap();
6869

6970
assert!(parent_folder.join("package.json").exists());
7071
fs::remove_dir_all(&parent_folder).unwrap();
72+
env::set_current_dir(&current_directory).unwrap();
7173
}
7274

7375
#[tokio::test]
7476
async fn init_command_should_throw_on_existing_file() {
77+
let current_directory = env::current_dir().unwrap();
7578
let parent_folder = prepare();
7679
let mut file = fs::File::create(parent_folder.join("package.json")).unwrap();
7780
file.write_all("{}".as_bytes()).unwrap();
7881
assert!(parent_folder.join("package.json").exists());
7982
let cli = Cli::parse_from(["", "init"]);
8083
run_commands(cli).await.expect_err("should have thrown");
8184
fs::remove_dir_all(&parent_folder).unwrap();
85+
env::set_current_dir(&current_directory).unwrap();
8286
}
8387
}

0 commit comments

Comments
 (0)