| 4292 | #[test] |
| 4293 | #[cfg(unix)] |
| 4294 | fn test_module_map_clean_dry_run() { |
| 4295 | let temp_dir = TempDir::new().unwrap(); |
| 4296 | let agents_dir = temp_dir.path().join(".agents"); |
| 4297 | let claude_dir = agents_dir.join("claude"); |
| 4298 | fs::create_dir_all(&claude_dir).unwrap(); |
| 4299 | fs::write(claude_dir.join("api-context.md"), "# API").unwrap(); |
| 4300 | |
| 4301 | fs::create_dir_all(temp_dir.path().join("src/api")).unwrap(); |
| 4302 | |
| 4303 | let config_path = agents_dir.join("agentsync.toml"); |
| 4304 | let config_content = r#" |
| 4305 | source_dir = "claude" |
| 4306 | |
| 4307 | [agents.claude] |
| 4308 | enabled = true |
| 4309 | |
| 4310 | [agents.claude.targets.modules] |
| 4311 | source = "." |
| 4312 | destination = "." |
| 4313 | type = "module-map" |
| 4314 | |
| 4315 | [[agents.claude.targets.modules.mappings]] |
| 4316 | source = "api-context.md" |
| 4317 | destination = "src/api" |
| 4318 | "#; |
| 4319 | fs::write(&config_path, config_content).unwrap(); |
| 4320 | |
| 4321 | let config = Config::load(&config_path).unwrap(); |
| 4322 | let linker = Linker::new(config, config_path); |
| 4323 | |
| 4324 | // Sync first |
| 4325 | linker.sync(&SyncOptions::default()).unwrap(); |
| 4326 | assert!(temp_dir.path().join("src/api/CLAUDE.md").is_symlink()); |
| 4327 | |
| 4328 | // Dry-run clean should NOT remove |
| 4329 | let result = linker |
| 4330 | .clean(&SyncOptions { |
| 4331 | dry_run: true, |
| 4332 | ..Default::default() |
| 4333 | }) |
| 4334 | .unwrap(); |
| 4335 | assert_eq!(result.removed, 1); // counted but not removed |
| 4336 | assert!(temp_dir.path().join("src/api/CLAUDE.md").is_symlink()); |
| 4337 | } |
| 4338 | |
| 4339 | #[test] |
| 4340 | #[cfg(unix)] |