Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Nov 22, 2023
1 parent 83eb97d commit 849c418
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions crates/cli/tests/install_uninstall_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ mod install_uninstall {
assert!(tools.tools.get("node").is_none());
}

#[cfg(not(windows))]
#[test]
fn symlinks_bin_when_pinning() {
let temp = create_empty_sandbox();
Expand All @@ -346,25 +347,17 @@ mod install_uninstall {
.arg("--no-bundled-npm")
.assert();

let link = temp
.path()
.join("bin")
.join(if cfg!(windows) { "node.exe" } else { "node" });
let link = temp.path().join("bin").join("node");

assert!(link.exists());

assert_eq!(
std::fs::read_link(link).unwrap(),
temp.path()
.join("tools/node/19.0.0")
.join(if cfg!(windows) {
"node.exe"
} else {
"bin/node"
})
temp.path().join("tools/node/19.0.0").join("bin/node")
);
}

#[cfg(not(windows))]
#[test]
fn symlinks_bin_on_first_install_without_pinning() {
let temp = create_empty_sandbox();
Expand All @@ -377,10 +370,44 @@ mod install_uninstall {
.arg("--no-bundled-npm")
.assert();

let link = temp
.path()
.join("bin")
.join(if cfg!(windows) { "node.exe" } else { "node" });
let link = temp.path().join("bin").join("node");

assert!(link.exists());
}

#[cfg(windows)]
#[test]
fn creates_bin_when_pinning() {
let temp = create_empty_sandbox();

let mut cmd = create_proto_command(temp.path());
cmd.arg("install")
.arg("node")
.arg("19.0.0")
.arg("--pin")
.arg("--")
.arg("--no-bundled-npm")
.assert();

let link = temp.path().join("bin").join("node.exe");

assert!(link.exists());
}

#[cfg(windows)]
#[test]
fn creates_bin_on_first_install_without_pinning() {
let temp = create_empty_sandbox();

let mut cmd = create_proto_command(temp.path());
cmd.arg("install")
.arg("node")
.arg("19.0.0")
.arg("--")
.arg("--no-bundled-npm")
.assert();

let link = temp.path().join("bin").join("node.exe");

assert!(link.exists());
}
Expand Down

0 comments on commit 849c418

Please sign in to comment.