Install the CLI with an overwriting symbolic link.
This commit is contained in:
@@ -1859,11 +1859,15 @@ mod tests {
|
||||
assert!(fixture.run(&["install"], "").is_err());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn launcher_install_is_idempotent_and_refuses_overwrite() {
|
||||
fn launcher_install_is_idempotent_and_overwrites_existing_file() {
|
||||
let fixture = Fixture::new(false);
|
||||
let executable = fixture._root.path().join("packaged-bds-cli");
|
||||
std::fs::write(&executable, b"binary").unwrap();
|
||||
let target = fixture.home_dir.join(".local/bin/bds-cli");
|
||||
std::fs::create_dir_all(target.parent().unwrap()).unwrap();
|
||||
std::fs::write(&target, b"old launcher").unwrap();
|
||||
let context = RunContext {
|
||||
executable_path: executable.clone(),
|
||||
..fixture.context("")
|
||||
@@ -1878,12 +1882,10 @@ mod tests {
|
||||
context,
|
||||
)
|
||||
.unwrap();
|
||||
let target = fixture.home_dir.join(".local/bin/bds-cli");
|
||||
assert!(!target.is_symlink());
|
||||
assert!(
|
||||
std::fs::read_to_string(target)
|
||||
.unwrap()
|
||||
.contains(executable.canonicalize().unwrap().to_str().unwrap())
|
||||
assert!(target.is_symlink());
|
||||
assert_eq!(
|
||||
std::fs::read_link(target).unwrap(),
|
||||
executable.canonicalize().unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user