Skip to content

Commit ef96749

Browse files
committed
test(cli/uninstall): 'uninstall -g' sub cmd with additional packages
1 parent 55cf53b commit ef96749

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

cli/args/flags.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8943,6 +8943,28 @@ mod tests {
89438943
..Flags::default()
89448944
}
89458945
);
8946+
8947+
let r = flags_from_vec(svec![
8948+
"deno",
8949+
"uninstall",
8950+
"-g",
8951+
"--root",
8952+
"/user/foo/bar",
8953+
"cowsay",
8954+
"file_server"
8955+
]);
8956+
assert_eq!(
8957+
r.unwrap(),
8958+
Flags {
8959+
subcommand: DenoSubcommand::Uninstall(UninstallFlags {
8960+
kind: UninstallKind::Global(UninstallFlagsGlobal {
8961+
packages: vec!["cowsay".to_string(), "file_server".to_string()],
8962+
root: Some("/user/foo/bar".to_string()),
8963+
}),
8964+
}),
8965+
..Flags::default()
8966+
}
8967+
);
89468968
}
89478969

89488970
#[test]

cli/tools/installer.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,9 +1587,16 @@ mod tests {
15871587

15881588
let mut file_path = bin_dir.join("echo_test");
15891589
File::create(&file_path).unwrap();
1590+
1591+
let mut second_file_path = bin_dir.join("second_echo_test");
1592+
File::create(&second_file_path).unwrap();
1593+
15901594
if cfg!(windows) {
15911595
file_path = file_path.with_extension("cmd");
15921596
File::create(&file_path).unwrap();
1597+
1598+
second_file_path = second_file_path.with_extension("cmd");
1599+
File::create(&second_file_path).unwrap();
15931600
}
15941601

15951602
// create extra files
@@ -1607,11 +1614,28 @@ mod tests {
16071614
File::create(file_path).unwrap();
16081615
}
16091616

1617+
{
1618+
let file_path = second_file_path.with_extension("deno.json");
1619+
File::create(file_path).unwrap();
1620+
}
1621+
{
1622+
// legacy tsconfig.json, make sure it's cleaned up for now
1623+
let file_path = second_file_path.with_extension("tsconfig.json");
1624+
File::create(file_path).unwrap();
1625+
}
1626+
{
1627+
let file_path = second_file_path.with_extension("lock.json");
1628+
File::create(file_path).unwrap();
1629+
}
1630+
16101631
uninstall(
16111632
Default::default(),
16121633
UninstallFlags {
16131634
kind: UninstallKind::Global(UninstallFlagsGlobal {
1614-
packages: vec!["echo_test".to_string()],
1635+
packages: vec![
1636+
"echo_test".to_string(),
1637+
"second_echo_test".to_string(),
1638+
],
16151639
root: Some(temp_dir.path().to_string()),
16161640
}),
16171641
},
@@ -1624,9 +1648,17 @@ mod tests {
16241648
assert!(!file_path.with_extension("deno.json").exists());
16251649
assert!(!file_path.with_extension("lock.json").exists());
16261650

1651+
assert!(!second_file_path.exists());
1652+
assert!(!second_file_path.with_extension("tsconfig.json").exists());
1653+
assert!(!second_file_path.with_extension("deno.json").exists());
1654+
assert!(!second_file_path.with_extension("lock.json").exists());
1655+
16271656
if cfg!(windows) {
16281657
file_path = file_path.with_extension("cmd");
16291658
assert!(!file_path.exists());
1659+
1660+
second_file_path = second_file_path.with_extension("cmd");
1661+
assert!(!second_file_path.exists());
16301662
}
16311663
}
16321664

0 commit comments

Comments
 (0)