use std::process::Command;
#[test]
#[serial_test::serial]
fn add_install_reload_flow() {
struct Guard(#[allow(dead_code)] tempfile::TempDir);
impl Drop for Guard {
fn drop(&mut self) {
std::env::remove_var("ATOMCODE_HOME");
}
}
let home = tempfile::tempdir().unwrap();
std::env::set_var("ATOMCODE_HOME", home.path());
let _guard = Guard(home);
let workspace = tempfile::tempdir().unwrap();
let repo = workspace.path().join("e2e");
std::fs::create_dir_all(repo.join("skills/sk")).unwrap();
std::fs::write(
repo.join("skills/sk/SKILL.md"),
"---\nname: sk\ndescription: e2e skill\n---\nbody",
)
.unwrap();
std::fs::create_dir_all(repo.join("commands")).unwrap();
std::fs::write(
repo.join("commands/c.md"),
"---\nname: c\ndescription: e2e cmd\n---\necho",
)
.unwrap();
Command::new("git")
.args(["init", "-q"])
.current_dir(&repo)
.status()
.unwrap();
Command::new("git")
.args(["config", "user.email", "t@t"])
.current_dir(&repo)
.status()
.unwrap();
Command::new("git")
.args(["config", "user.name", "t"])
.current_dir(&repo)
.status()
.unwrap();
Command::new("git")
.args(["add", "-A"])
.current_dir(&repo)
.status()
.unwrap();
Command::new("git")
.args(["commit", "-q", "-m", "init"])
.current_dir(&repo)
.status()
.unwrap();
let url = format!("file://{}", repo.display());
atomcode_core::plugin::marketplace::add_marketplace(&url).unwrap();
atomcode_core::plugin::installer::install("e2e", "e2e", atomcode_core::plugin::InstallScope::User).unwrap();
let working = tempfile::tempdir().unwrap();
let mut reg = atomcode_core::skill::SkillRegistry::new();
reg.reload(working.path());
assert!(reg.get("e2e:sk").is_some(), "missing skill e2e:sk");
let creg = atomcode_core::commands::CustomCommandRegistry::load(working.path());
assert!(creg.get("e2e:c").is_some(), "missing command e2e:c");
}