()
| 1564 | |
| 1565 | #[test] |
| 1566 | fn test_install_structure() { |
| 1567 | let config = temp_config(); |
| 1568 | AgyHook::install_to(config.path(), false).unwrap(); |
| 1569 | |
| 1570 | let hooks_path = config.path().join("plugins/atomic/hooks.json"); |
| 1571 | let parsed: Value = |
| 1572 | serde_json::from_str(&std::fs::read_to_string(&hooks_path).unwrap()).unwrap(); |
| 1573 | |
| 1574 | let group = parsed.get("atomic").unwrap(); |
| 1575 | |
| 1576 | // Lifecycle events are direct handler lists. |
| 1577 | let pre = group.get("PreInvocation").unwrap().as_array().unwrap(); |
| 1578 | assert_eq!(pre.len(), 1); |
| 1579 | assert!(pre[0].get("command").is_some()); |
| 1580 | |
| 1581 | let stop = group.get("Stop").unwrap().as_array().unwrap(); |
| 1582 | assert_eq!(stop.len(), 1); |
| 1583 | assert!(stop[0].get("command").is_some()); |
| 1584 | |
| 1585 | // Tool events are matcher groups. |
| 1586 | let post = group.get("PostToolUse").unwrap().as_array().unwrap(); |
| 1587 | assert_eq!(post.len(), 1); |
| 1588 | assert_eq!(post[0].get("matcher").and_then(Value::as_str), Some("")); |
| 1589 | let hooks = post[0].get("hooks").unwrap().as_array().unwrap(); |
| 1590 | assert_eq!(hooks.len(), 1); |
| 1591 | assert!(hooks[0] |
| 1592 | .get("command") |
| 1593 | .and_then(Value::as_str) |
| 1594 | .unwrap() |
| 1595 | .contains("post-tool-use")); |
| 1596 | |
| 1597 | // Hook commands are bare (no cwd guard) — plugin hooks do not run |
| 1598 | // with the workspace as cwd. |
| 1599 | let command = stop[0].get("command").and_then(Value::as_str).unwrap(); |
| 1600 | assert!(!command.contains("test -d")); |
| 1601 | } |
| 1602 | |
| 1603 | #[test] |
| 1604 | fn test_install_idempotent() { |
nothing calls this directly
no test coverage detected