Da9494b768,e1ce139ae1c278642: crate akode-update (ultima release da git.difonzo.net/andrea/imeai-aKode, confronto semver, download solo dallo stesso host, verifica SHA-256, sostituzione atomica), `akode update [--check]`, riga di avviso nella TUI, controllo in background all'avvio al massimo ogni 24 h (disattivabile con [update] check_on_startup = false; non installa mai nulla da solo). Nessun contatto con OpenAI o altri domini; il sistema upstream (curl chatgpt.com/codex/install.sh, npm, brew) resta rimosso. Lasciato fuori l'allineamento del daemon (95f4ddcd). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
64 lines
1.8 KiB
Rust
64 lines
1.8 KiB
Rust
use anyhow::Result;
|
|
use predicates::str::contains;
|
|
use std::path::Path;
|
|
use tempfile::TempDir;
|
|
use wiremock::Mock;
|
|
use wiremock::MockServer;
|
|
use wiremock::ResponseTemplate;
|
|
use wiremock::matchers::method;
|
|
use wiremock::matchers::path;
|
|
|
|
const LATEST_PATH: &str = "/api/v1/repos/andrea/aKode/releases/latest";
|
|
|
|
fn akode_update(akode_home: &Path, server: &MockServer) -> Result<assert_cmd::Command> {
|
|
let mut cmd = assert_cmd::Command::new(akode_utils_cargo_bin::cargo_bin("akode")?);
|
|
cmd.env("AKODE_HOME", akode_home).args([
|
|
"-c",
|
|
&format!("update.repo_url=\"{}/andrea/aKode\"", server.uri()),
|
|
"update",
|
|
]);
|
|
Ok(cmd)
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn update_without_published_release_reports_up_to_date() -> Result<()> {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("GET"))
|
|
.and(path(LATEST_PATH))
|
|
.respond_with(ResponseTemplate::new(404))
|
|
.expect(1)
|
|
.mount(&server)
|
|
.await;
|
|
let akode_home = TempDir::new()?;
|
|
|
|
akode_update(akode_home.path(), &server)?
|
|
.assert()
|
|
.success()
|
|
.stdout(contains("Nessuna release pubblicata"));
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn update_check_reports_newer_release_without_installing() -> Result<()> {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("GET"))
|
|
.and(path(LATEST_PATH))
|
|
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
|
"tag_name": "v999.0.0",
|
|
"assets": [],
|
|
})))
|
|
.expect(1)
|
|
.mount(&server)
|
|
.await;
|
|
let akode_home = TempDir::new()?;
|
|
|
|
akode_update(akode_home.path(), &server)?
|
|
.arg("--check")
|
|
.assert()
|
|
.success()
|
|
.stdout(contains("È disponibile aKode 999.0.0"));
|
|
|
|
Ok(())
|
|
}
|