Clarify hook source assertions

This commit is contained in:
Abhinav Vedmala
2026-05-01 15:50:05 -07:00
parent 77b1a9c413
commit bcb465f4cb
2 changed files with 13 additions and 7 deletions
+3 -2
View File
@@ -610,11 +610,12 @@ mod tests {
path: &'a AbsolutePathBuf,
hook_states: &'a std::collections::HashMap<String, HookStateToml>,
) -> super::HookHandlerSource<'a> {
let source = hook_source();
super::HookHandlerSource {
path,
key_source: path.display().to_string(),
source: hook_source(),
is_managed: hook_source().is_managed(),
source,
is_managed: source.is_managed(),
hook_states,
env: std::collections::HashMap::new(),
plugin_id: None,
+10 -5
View File
@@ -123,7 +123,7 @@ with Path(r"{log_path}").open("a", encoding="utf-8") as handle:
assert!(engine.warnings().is_empty());
assert_eq!(engine.handlers.len(), 1);
assert!(engine.handlers[0].source.is_managed());
assert_eq!(engine.handlers[0].source, HookSource::CloudRequirements);
let listed = crate::list_hooks(crate::HooksConfig {
legacy_notify_argv: None,
feature_enabled: true,
@@ -293,7 +293,7 @@ fn user_disablement_filters_non_managed_hooks_but_not_managed_hooks() {
);
assert_eq!(engine.handlers.len(), 1);
assert!(engine.handlers[0].source.is_managed());
assert_eq!(engine.handlers[0].source, HookSource::CloudRequirements);
let discovered =
super::discovery::discover_handlers(Some(&config_layer_stack), Vec::new(), Vec::new());
assert_eq!(discovered.hook_entries.len(), 2);
@@ -350,7 +350,10 @@ fn user_disablement_does_not_filter_managed_layer_hooks() {
);
assert_eq!(engine.handlers.len(), 1);
assert!(engine.handlers[0].source.is_managed());
assert_eq!(
engine.handlers[0].source,
HookSource::LegacyManagedConfigFile
);
let discovered =
super::discovery::discover_handlers(Some(&config_layer_stack), Vec::new(), Vec::new());
assert_eq!(discovered.hook_entries.len(), 1);
@@ -732,11 +735,13 @@ fn discovers_hooks_from_json_and_toml_in_the_same_layer() {
tool_input: serde_json::json!({ "command": "echo hello" }),
});
assert_eq!(preview.len(), 2);
assert!(
assert_eq!(
engine
.handlers
.iter()
.all(|handler| handler.source.is_managed())
.map(|handler| handler.source)
.collect::<Vec<_>>(),
vec![HookSource::System, HookSource::System]
);
assert_eq!(preview[0].source_path, hooks_json_path);
assert_eq!(preview[1].source_path, config_path);