Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

test(cli): cover --project-strategy parsing and rejection

João Matheusb6f1891af7e9
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rs
index 7b550a8f..a7f1418d 100644
--- a/crates/ai-memory-cli/src/cli.rs
+++ b/crates/ai-memory-cli/src/cli.rs
@@ -1581,6 +1581,51 @@ mod tests {
assert!(matches!(hook_args.agent, AgentChoice::Grok));
}
+ #[test]
+ fn install_hooks_project_strategy_repo_root_parses() {
+ let cli = Cli::try_parse_from([
+ "ai-memory",
+ "install-hooks",
+ "--agent",
+ "claude-code",
+ "--project-strategy",
+ "repo-root",
+ ])
+ .unwrap_or_else(|e| panic!("failed to parse --project-strategy repo-root: {e}"));
+ let Command::InstallHooks(args) = cli.command else {
+ panic!("expected install-hooks command");
+ };
+ assert!(matches!(
+ args.project_strategy,
+ ProjectStrategyArg::RepoRoot
+ ));
+ assert_eq!(args.project_strategy.baked(), Some("repo-root"));
+ }
+
+ #[test]
+ fn install_hooks_project_strategy_defaults_to_basename() {
+ let cli = Cli::try_parse_from(["ai-memory", "install-hooks", "--agent", "claude-code"])
+ .expect("install-hooks parses without --project-strategy");
+ let Command::InstallHooks(args) = cli.command else {
+ panic!("expected install-hooks command");
+ };
+ assert!(matches!(
+ args.project_strategy,
+ ProjectStrategyArg::Basename
+ ));
+ assert_eq!(args.project_strategy.baked(), None);
+ }
+
+ #[test]
+ fn install_hooks_project_strategy_rejects_invalid_value() {
+ let result =
+ Cli::try_parse_from(["ai-memory", "install-hooks", "--project-strategy", "bogus"]);
+ assert!(
+ result.is_err(),
+ "an unknown --project-strategy value must be rejected by value_enum"
+ );
+ }
+
#[test]
fn vscode_copilot_aliases_parse_to_same_variant() {
for alias in ["vscode-copilot", "copilot", "github-copilot"] {