mod common;
use predicates::prelude::*;
#[test]
fn test_install_bypasses_menu_when_subdirectory_specified() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("repo");
workspace.create_bundle("repo/bundle-a");
workspace.create_bundle("repo/bundle-b");
workspace.write_file(
"repo/bundle-a/augent.yaml",
r#"name: "@test/bundle-a"
bundles: []
"#,
);
workspace.write_file("repo/bundle-a/commands/a.md", "# A\n");
workspace.write_file(
"repo/bundle-b/augent.yaml",
r#"name: "@test/bundle-b"
bundles: []
"#,
);
workspace.write_file("repo/bundle-b/commands/b.md", "# B\n");
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./repo/bundle-a", "--to", "claude"])
.assert()
.success()
.stdout(predicate::str::contains("Installed 1 bundle"));
assert!(workspace.file_exists(".claude/commands/a.md"));
assert!(!workspace.file_exists(".claude/commands/b.md"));
}
#[test]
fn test_install_with_explicit_path_does_not_show_menu() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("my-bundle");
workspace.write_file(
"bundles/my-bundle/augent.yaml",
r#"name: "@test/my-bundle"
bundles: []
"#,
);
workspace.write_file("bundles/my-bundle/commands/test.md", "# Test\n");
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./bundles/my-bundle", "--to", "claude"])
.assert()
.success();
assert!(workspace.file_exists(".claude/commands/test.md"));
}
#[test]
fn test_menu_displays_bundle_with_description() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("repo");
workspace.create_bundle("repo/with-desc");
workspace.write_file(
"repo/with-desc/augent.yaml",
r#"name: "@test/with-desc"
description: "A test bundle with description"
bundles: []
"#,
);
workspace.write_file("repo/with-desc/commands/test.md", "# Test\n");
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./repo/with-desc", "--to", "claude"])
.assert()
.success();
assert!(workspace.file_exists(".claude/commands/test.md"));
}
#[test]
fn test_install_handles_repository_with_single_bundle() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("repo");
workspace.create_bundle("repo/plugins");
workspace.write_file(
"repo/plugins/augent.yaml",
r#"name: "@test/plugins"
bundles: []
"#,
);
workspace.write_file("repo/plugins/commands/test.md", "# Test\n");
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./repo/plugins", "--to", "claude"])
.assert()
.success()
.stdout(predicate::str::contains("Installed 1 bundle"));
assert!(workspace.file_exists(".claude/commands/test.md"));
}
#[test]
fn test_install_handles_repository_with_empty_subdirectories() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("repo");
workspace.create_bundle("repo/empty-dir");
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./repo", "--to", "claude"])
.assert()
.failure();
}
#[test]
fn test_install_handles_repository_with_non_bundle_subdirectories() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("repo");
workspace.create_bundle("repo/bundle");
workspace.write_file(
"repo/bundle/augent.yaml",
r#"name: "@test/bundle"
bundles: []
"#,
);
workspace.write_file("repo/bundle/commands/test.md", "# Test\n");
workspace.write_file("repo/random-dir/file.txt", "content\n");
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./repo/bundle", "--to", "claude"])
.assert()
.success();
assert!(workspace.file_exists(".claude/commands/test.md"));
}
#[test]
fn test_install_with_multiple_bundles_from_single_source() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("repo");
workspace.create_bundle("repo/bundle-1");
workspace.create_bundle("repo/bundle-2");
workspace.write_file(
"repo/bundle-1/augent.yaml",
r#"name: "@test/bundle-1"
bundles: []
"#,
);
workspace.write_file("repo/bundle-1/commands/one.md", "# One\n");
workspace.write_file(
"repo/bundle-2/augent.yaml",
r#"name: "@test/bundle-2"
bundles: []
"#,
);
workspace.write_file("repo/bundle-2/commands/two.md", "# Two\n");
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./repo/bundle-1", "--to", "claude"])
.assert()
.success();
assert!(workspace.file_exists(".claude/commands/one.md"));
assert!(!workspace.file_exists(".claude/commands/two.md"));
}
#[test]
fn test_install_explicit_subdirectory_overrides_discovery() {
let workspace = common::TestWorkspace::new();
workspace.init_from_fixture("empty");
workspace.create_agent_dir("claude");
workspace.create_bundle("repo");
workspace.create_bundle("repo/bundle-1");
workspace.create_bundle("repo/bundle-2");
workspace.create_bundle("repo/bundle-3");
for i in 1..=3 {
let name = format!("bundle-{}", i);
workspace.write_file(
&format!("repo/{}/augent.yaml", name),
&format!(
r#"name: "@test/{}"
bundles: []
"#,
name
),
);
workspace.write_file(
&format!("repo/{}/commands/{}.md", name, i),
&format!("# {}\n", i),
);
}
common::augent_cmd_for_workspace(&workspace.path)
.args(["install", "./repo/bundle-2", "--to", "claude"])
.assert()
.success();
assert!(!workspace.file_exists(".claude/commands/1.md"));
assert!(workspace.file_exists(".claude/commands/2.md"));
assert!(!workspace.file_exists(".claude/commands/3.md"));
}