mod common;
use predicates::prelude::PredicateBooleanExt;
#[test]
fn test_install_dir_bundle_with_path() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("cursor");
workspace.create_bundle("my-local-bundle");
workspace.write_file(
"bundles/my-local-bundle/commands/hello.md",
"# Hello Command\n",
);
common::augent_cmd_for_workspace(&workspace.path)
.args([
"install",
"./bundles/my-local-bundle",
"--to",
"cursor",
"-y",
])
.assert()
.success();
let augent_yaml = std::fs::read_to_string(workspace.path.join(".augent/augent.yaml"))
.expect("Failed to read augent.yaml");
assert!(augent_yaml.contains("name: my-local-bundle"));
assert!(augent_yaml.contains("path: ./bundles/my-local-bundle"));
assert!(workspace.path.join(".cursor/commands/hello.md").exists());
}
#[test]
fn test_install_current_directory_as_bundle() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("cursor");
let bundle_dir = workspace.path.join("my-bundle");
std::fs::create_dir_all(&bundle_dir).expect("Failed to create bundle directory");
workspace.write_file("my-bundle/commands/test.md", "# Test Command\n");
workspace.write_file("my-bundle/augent.yaml", "name: \"my-bundle\"\n");
std::env::set_current_dir(&bundle_dir).expect("Failed to set current directory");
common::augent_cmd_for_workspace(&workspace.path)
.current_dir(&bundle_dir)
.args(["install", ".", "--to", "cursor", "-y"])
.assert()
.success();
let augent_yaml = std::fs::read_to_string(workspace.path.join(".augent/augent.yaml"))
.expect("Failed to read augent.yaml");
assert!(augent_yaml.contains("name: my-bundle"));
assert!(augent_yaml.contains("path: ./my-bundle"));
assert!(workspace.path.join(".cursor/commands/test.md").exists());
}
#[test]
fn test_install_path_outside_repository_fails() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
common::augent_cmd_for_workspace(&workspace.path)
.args([
"install",
"/some/absolute/path/outside/repo",
"--to",
"cursor",
])
.assert()
.failure()
.stderr(
predicates::str::contains("outside repository")
.or(predicates::str::contains("within repository"))
.or(predicates::str::contains("workspace")),
);
}
#[test]
fn test_install_existing_dir_bundle_path() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("cursor");
workspace.create_bundle("existing-bundle");
workspace.write_file(
"bundles/existing-bundle/commands/existing.md",
"# Existing Command\n",
);
workspace.write_file(
"bundles/existing-bundle/augent.yaml",
"name: \"existing-bundle\"\n",
);
common::augent_cmd_for_workspace(&workspace.path)
.args([
"install",
"./bundles/existing-bundle",
"--to",
"cursor",
"-y",
])
.assert()
.success();
let augent_yaml = std::fs::read_to_string(workspace.path.join(".augent/augent.yaml"))
.expect("Failed to read augent.yaml");
assert!(augent_yaml.contains("name: existing-bundle"));
assert!(workspace.path.join(".cursor/commands/existing.md").exists());
assert!(
!workspace.path.join(".cursor/commands/updated.md").exists(),
"Updated file should not exist after first install"
);
workspace.write_file(
"bundles/existing-bundle/commands/updated.md",
"# Updated Command\n",
);
common::augent_cmd_for_workspace(&workspace.path)
.args([
"install",
"./bundles/existing-bundle",
"--to",
"cursor",
"-y",
])
.assert()
.success();
assert!(workspace.path.join(".cursor/commands/updated.md").exists());
}