github source v1

This commit is contained in:
stoorps 2026-03-19 20:14:39 +00:00
parent 71f89dde9c
commit caf870d05e
Signed by: stoorps
SSH key fingerprint: SHA256:AZlPfu9hTu042EGtZElmDQoy+KvMOeShLDan/fYLoNI
50 changed files with 4139 additions and 131 deletions

View file

@ -2,6 +2,8 @@ use assert_cmd::Command;
use predicates::str::contains;
use tempfile::tempdir;
const FIXTURE_MODE_ENV: &str = "AIM_GITHUB_FIXTURE_MODE";
#[test]
fn list_command_runs_without_registry_entries() {
let mut cmd = Command::cargo_bin("aim").unwrap();
@ -52,3 +54,58 @@ fn remove_command_removes_registered_app_from_registry_file() {
let contents = std::fs::read_to_string(&registry_path).unwrap();
assert!(!contents.contains("stable_id = \"bat\""));
}
#[test]
fn query_command_registers_unambiguous_app_in_registry_file() {
let dir = tempdir().unwrap();
let registry_path = dir.path().join("registry.toml");
let mut cmd = Command::cargo_bin("aim").unwrap();
cmd.arg("sharkdp/bat")
.env("AIM_REGISTRY_PATH", &registry_path)
.env(FIXTURE_MODE_ENV, "1")
.assert()
.success()
.stdout(contains("tracked app: bat (sharkdp-bat)"));
let contents = std::fs::read_to_string(&registry_path).unwrap();
assert!(contents.contains("stable_id = \"sharkdp-bat\""));
assert!(contents.contains("source_input = \"sharkdp/bat\""));
}
#[test]
fn old_release_query_renders_tracking_prompt_without_writing_registry() {
let dir = tempdir().unwrap();
let registry_path = dir.path().join("registry.toml");
let mut cmd = Command::cargo_bin("aim").unwrap();
cmd.arg("https://github.com/pingdotgg/t3code/releases/download/v0.0.11/T3-Code-0.0.11-x86_64.AppImage")
.env("AIM_REGISTRY_PATH", &registry_path)
.env(FIXTURE_MODE_ENV, "1")
.assert()
.success()
.stdout(contains("tracking preference required"))
.stdout(contains("v0.0.11"))
.stdout(contains("v0.0.12"));
assert!(!registry_path.exists());
}
#[test]
fn old_release_query_can_track_latest_and_register_app() {
let dir = tempdir().unwrap();
let registry_path = dir.path().join("registry.toml");
let mut cmd = Command::cargo_bin("aim").unwrap();
cmd.arg("https://github.com/pingdotgg/t3code/releases/download/v0.0.11/T3-Code-0.0.11-x86_64.AppImage")
.env("AIM_REGISTRY_PATH", &registry_path)
.env(FIXTURE_MODE_ENV, "1")
.env("AIM_TRACKING_PREFERENCE", "latest")
.assert()
.success()
.stdout(contains("tracked app: t3code (pingdotgg-t3code)"));
let contents = std::fs::read_to_string(&registry_path).unwrap();
assert!(contents.contains("stable_id = \"pingdotgg-t3code\""));
assert!(contents.contains("locator = \"pingdotgg/t3code\""));
}

View file

@ -1,7 +1,24 @@
use aim_cli::ui::prompt::render_interaction;
use aim_cli::ui::render::render_update_summary;
use aim_core::app::interaction::{InteractionKind, InteractionRequest};
#[test]
fn update_summary_mentions_selected_count() {
let output = render_update_summary(3, 2, 1);
assert!(output.contains("selected: 2"));
}
#[test]
fn tracking_prompt_mentions_requested_and_latest_versions() {
let output = render_interaction(&InteractionRequest {
key: "tracking-preference".to_owned(),
kind: InteractionKind::ChooseTrackingPreference {
requested_version: "v0.0.11".to_owned(),
latest_version: "v0.0.12".to_owned(),
},
});
assert!(output.contains("tracking preference required"));
assert!(output.contains("v0.0.11"));
assert!(output.contains("v0.0.12"));
}