Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Dec 2, 2024
1 parent 99aba4b commit bc76aeb
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions crates/cli/tests/bin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ mod bin {
let sandbox = create_empty_proto_sandbox();

let assert = sandbox.run_bin(|cmd| {
cmd.arg("bin").arg("npm").arg("9.0.0");
cmd.arg("bin").arg("node").arg("19.0.0");
});

assert.inner.stderr(predicate::str::contains(
"Unable to find an executable for npm",
"Unable to find an executable for Node.js",
));
}

Expand All @@ -25,22 +25,22 @@ mod bin {

sandbox
.run_bin(|cmd| {
cmd.arg("install").arg("npm").arg("9.0.0");
cmd.arg("install").arg("node").arg("19.0.0");
})
.success();

let assert = sandbox.run_bin(|cmd| {
cmd.arg("bin").arg("npm").arg("9.0.0");
cmd.arg("bin").arg("node").arg("19.0.0");
});

if cfg!(windows) {
assert.inner.stdout(predicate::str::contains(
"tools\\npm\\9.0.0\\bin/npm-cli.js",
));
assert
.inner
.stdout(predicate::str::contains("tools\\node\\19.0.0\\node.exe"));
} else {
assert
.inner
.stdout(predicate::str::contains("tools/npm/9.0.0/bin/npm-cli.js"));
.stdout(predicate::str::contains("tools/node/19.0.0/bin/node"));
}
}

Expand All @@ -50,20 +50,18 @@ mod bin {

sandbox
.run_bin(|cmd| {
cmd.arg("install").arg("npm").arg("9.0.0");
cmd.arg("install").arg("node").arg("19.0.0");
})
.success();

let assert = sandbox.run_bin(|cmd| {
cmd.arg("bin").arg("npm").arg("9.0.0").arg("--bin");
cmd.arg("bin").arg("node").arg("19.0.0").arg("--bin");
});

if cfg!(windows) {
assert
.inner
.stdout(predicate::str::contains("bin/npm-cli.js"));
assert.inner.stdout(predicate::str::contains("node.exe"));
} else {
assert.inner.stdout(predicate::str::contains("bin/npm"));
assert.inner.stdout(predicate::str::contains("bin/node"));
}
}

Expand All @@ -73,20 +71,20 @@ mod bin {

sandbox
.run_bin(|cmd| {
cmd.arg("install").arg("npm").arg("9.0.0");
cmd.arg("install").arg("node").arg("19.0.0");
})
.success();

let assert = sandbox.run_bin(|cmd| {
cmd.arg("bin").arg("npm").arg("9.0.0").arg("--shim");
cmd.arg("bin").arg("node").arg("19.0.0").arg("--shim");
});

if cfg!(windows) {
assert
.inner
.stdout(predicate::str::contains("shims\\npm.exe"));
.stdout(predicate::str::contains("shims\\node.exe"));
} else {
assert.inner.stdout(predicate::str::contains("shims/npm"));
assert.inner.stdout(predicate::str::contains("shims/node"));
}
}
}

0 comments on commit bc76aeb

Please sign in to comment.