Files
luxe/crates/luxe-core/src/update/installer/tests.rs
Evan Whittaker f3ed35beb5 luxe 0.1.5: a provider picker, model ids, and a guided review that says less
The dock's provider row opens a list of providers, and the model picker opens on the provider in use, with tab to widen it; signing in opens it on the provider just signed in to. Models go by their id unless config names them, and the model row wears its maker's mark.

The guided review's guide prompt is shorter, the pull request brief shows the start of the description with the rest behind p, its commits drop the Luxe-review and Luxe-revision lines, and the weakened-gates signal is gone.

luxe update reruns the installer it was installed with, in place of luxe-cli-update. The preview's FILE tab reads files the session changed outside the project, and only those. Smaller fixes: bash headers are highlighted, the preview loses a blank row, the launcher divider sits inside its frame, and the phone app's top bar is clear of iOS's blur.

rustls-webpki 0.103.16 and webpki-roots 1.0.10 fix RUSTSEC-2026-0381 and RUSTSEC-2026-0382, and vite 8.3.4 fixes GHSA-587h-7wmj-h5pm, GHSA-698v-4r3x-3vcv and GHSA-r825-w8mm-5pxw.
2026-10-22 13:25:32 -05:00

82 lines
4.1 KiB
Rust

use super::*;
/// The receipt the 0.1.4 PowerShell installer writes, its placeholders filled the way the script
/// fills them for an install into `~/.local/bin`.
const WINDOWS_RECEIPT: &str = r#"{"binaries":["luxe"],"binary_aliases":{},"cdylibs":[],"cstaticlibs":[],"install_layout":"flat","install_prefix":"C:\\Users\\dev\\.local\\bin","modify_path":true,"provider":{"source":"cargo-dist","version":"0.33.0"},"source":{"app_name":"luxe-cli","name":"luxe","owner":"evanwhittaker","release_type":"github"},"version":"0.1.4"}"#;
/// The real receipt reads, and the two fields an update needs come out of it.
#[test]
fn a_real_receipt_names_where_and_whether_path_was_edited() {
let receipt = InstallReceipt::parse(WINDOWS_RECEIPT).expect("the installer's receipt parses");
assert_eq!(receipt.install_prefix, PathBuf::from(r"C:\Users\dev\.local\bin"));
assert!(receipt.modify_path);
let declined = WINDOWS_RECEIPT.replace(r#""modify_path":true"#, r#""modify_path":false"#);
assert!(!InstallReceipt::parse(&declined).expect("parses").modify_path);
}
/// Something that is not a receipt is no receipt, rather than an installer copy in the wrong place.
#[test]
fn a_broken_receipt_is_none() {
assert_eq!(InstallReceipt::parse("{"), None);
assert_eq!(InstallReceipt::parse(r#"{"version":"0.1.4"}"#), None, "no prefix, no install");
}
/// A receipt covers a binary in its prefix, or in its `bin` for Cargo's layout, and nothing else.
#[test]
fn a_receipt_covers_only_its_own_directory() {
let dir = tempfile::tempdir().expect("tempdir");
let bin = dir.path().join("bin");
std::fs::create_dir_all(&bin).expect("bin");
let receipt =
|prefix: &Path| InstallReceipt { install_prefix: prefix.into(), modify_path: true };
assert!(receipt(&bin).covers(&bin.join("luxe")), "flat: the prefix itself");
assert!(receipt(dir.path()).covers(&bin.join("luxe")), "cargo layout: the prefix's bin");
assert!(!receipt(&bin).covers(&dir.path().join("luxe")), "the prefix's parent is not it");
assert!(!receipt(Path::new("/nowhere")).covers(&bin.join("luxe")));
}
/// The update goes where the receipt says, with its `PATH` choice; without a receipt for this
/// binary, beside the binary with `PATH` untouched.
#[test]
fn the_target_follows_the_receipt_and_falls_back_to_the_binary() {
let dir = tempfile::tempdir().expect("tempdir");
let luxe = dir.path().join("luxe");
let mine = InstallReceipt { install_prefix: dir.path().into(), modify_path: true };
let other = InstallReceipt { install_prefix: "/elsewhere".into(), modify_path: true };
let target = InstallTarget::for_binary(&luxe, Some(&mine)).expect("a target");
assert_eq!(target, InstallTarget { dir: dir.path().into(), modify_path: true });
for receipt in [None, Some(&other)] {
let target = InstallTarget::for_binary(&luxe, receipt).expect("a target");
assert_eq!(target, InstallTarget { dir: dir.path().into(), modify_path: false });
}
}
/// The variables are the ones the 0.1.4 scripts read (`$env:LUXE_CLI_INSTALL_DIR`,
/// `LUXE_CLI_NO_MODIFY_PATH`), and the switch that would stop the receipt is never among them.
#[test]
fn the_script_variables_are_the_ones_the_installer_reads() {
let names = |target: InstallTarget| -> Vec<String> {
target.script_variables().into_iter().map(|(name, _)| name).collect()
};
let edits = InstallTarget { dir: "/home/dev/.local/bin".into(), modify_path: true };
assert_eq!(names(edits.clone()), ["LUXE_CLI_INSTALL_DIR"]);
assert_eq!(edits.script_variables()[0].1, OsString::from("/home/dev/.local/bin"));
let keeps = InstallTarget { modify_path: false, ..edits };
assert_eq!(names(keeps), ["LUXE_CLI_INSTALL_DIR", "LUXE_CLI_NO_MODIFY_PATH"]);
}
/// The script's address is the one the install instructions give, for this platform's script.
#[test]
fn the_script_url_is_the_releases_own() {
let script = if cfg!(windows) { "luxe-cli-installer.ps1" } else { "luxe-cli-installer.sh" };
assert_eq!(
installer_script_url("v0.1.5"),
format!("https://github.com/evanwhittaker/luxe/releases/download/v0.1.5/{script}")
);
}