()
| 1078 | |
| 1079 | #[test] |
| 1080 | fn test_save_dedup() { |
| 1081 | let dir = TempDir::new().unwrap(); |
| 1082 | let claude_md = dir.path().join("CLAUDE.md"); |
| 1083 | |
| 1084 | // First save |
| 1085 | let learnings = Learnings { |
| 1086 | repo: vec!["Learning A".into(), "Learning B".into()], |
| 1087 | code: vec![], |
| 1088 | workflow: vec![], |
| 1089 | }; |
| 1090 | save_learnings_to_context_file(dir.path(), "claude-code", &learnings).unwrap(); |
| 1091 | |
| 1092 | // Second save with overlap |
| 1093 | let learnings2 = Learnings { |
| 1094 | repo: vec![ |
| 1095 | "Learning A".into(), // duplicate |
| 1096 | "Learning C".into(), // new |
| 1097 | ], |
| 1098 | code: vec![], |
| 1099 | workflow: vec![], |
| 1100 | }; |
| 1101 | let result = |
| 1102 | save_learnings_to_context_file(dir.path(), "claude-code", &learnings2).unwrap(); |
| 1103 | |
| 1104 | assert_eq!(result.added, 1); // only C |
| 1105 | assert_eq!(result.skipped_duplicates, 1); // A was skipped |
| 1106 | |
| 1107 | let content = std::fs::read_to_string(&claude_md).unwrap(); |
| 1108 | // A should appear once, not twice |
| 1109 | assert_eq!(content.matches("Learning A").count(), 1); |
| 1110 | assert!(content.contains("Learning B")); |
| 1111 | assert!(content.contains("Learning C")); |
| 1112 | } |
| 1113 | |
| 1114 | #[test] |
| 1115 | fn test_save_merge_no_heading_duplication() { |
nothing calls this directly
no test coverage detected