- Nuovo crate akode-update: legge l'ultima release dal repository Gitea configurato ([update] repo_url, predefinito git.difonzo.net/andrea/aKode; 404 = nessun aggiornamento), confronta la semver, scarica akode-<versione>-<target>.tar.gz solo dallo stesso host, verifica lo SHA-256 e sostituisce il binario in modo atomico tenendo akode.old (nel layout a pacchetto aggiorna anche akode-package.json o l'intero pacchetto). - `akode update [--check]` con messaggi in italiano; mai installazioni automatiche. - TUI: controllo in background all'avvio al massimo ogni 24 h (update-check.json in AKODE_HOME), avviso su una riga, disattivabile con [update] check_on_startup = false. - Rimossi il prompt di aggiornamento e le azioni npm/brew/installer di OpenAI ormai inutilizzati; il doctor mostra sorgente e ultimo controllo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.3 KiB
Rust
40 lines
1.3 KiB
Rust
#![cfg(test)]
|
|
|
|
use super::*;
|
|
use akode_tui::DaemonUpdateSource;
|
|
use pretty_assertions::assert_eq;
|
|
use std::os::unix::fs::PermissionsExt;
|
|
|
|
#[test]
|
|
fn daemon_handoff_uses_selected_executable_and_propagates_failure() -> anyhow::Result<()> {
|
|
let dir = tempfile::tempdir()?;
|
|
let executable = dir.path().join("launching CLI");
|
|
let receipt = dir.path().join("launching CLI.args");
|
|
akode_utils_cargo_bin::write_executable(
|
|
&executable,
|
|
"#!/bin/sh\nprintf '%s\\n' \"$@\" > \"$0.args\"\n",
|
|
)?;
|
|
std::fs::set_permissions(&executable, std::fs::Permissions::from_mode(/*mode*/ 0o700))?;
|
|
for (source, expected) in [
|
|
(
|
|
DaemonUpdateSource::PublicStable,
|
|
"app-server\ndaemon\nupdate\n",
|
|
),
|
|
(
|
|
DaemonUpdateSource::ThisCli,
|
|
"app-server\ndaemon\nupdate\n--from-cli\n--yes\n",
|
|
),
|
|
] {
|
|
run_update_action(UpdateAction::Daemon(source), Some(&executable))?;
|
|
assert_eq!(std::fs::read_to_string(&receipt)?, expected);
|
|
}
|
|
akode_utils_cargo_bin::write_executable(&executable, "#!/bin/sh\nexit 7\n")?;
|
|
let error = run_update_action(
|
|
UpdateAction::Daemon(DaemonUpdateSource::ThisCli),
|
|
Some(&executable),
|
|
)
|
|
.unwrap_err();
|
|
assert!(error.to_string().contains("Daemon update failed"));
|
|
Ok(())
|
|
}
|