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