MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_save_merge_no_heading_duplication

Function test_save_merge_no_heading_duplication

atomic-agent/src/learnings.rs:1115–1155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1113
1114 #[test]
1115 fn test_save_merge_no_heading_duplication() {
1116 let dir = TempDir::new().unwrap();
1117 let claude_md = dir.path().join("CLAUDE.md");
1118
1119 // First save creates section with Repo
1120 let learnings1 = Learnings {
1121 repo: vec!["Learning A".into()],
1122 code: vec![],
1123 workflow: vec!["Tip X".into()],
1124 };
1125 save_learnings_to_context_file(dir.path(), "claude-code", &learnings1).unwrap();
1126
1127 // Second save adds more to Repo and Workflow
1128 let learnings2 = Learnings {
1129 repo: vec!["Learning B".into()],
1130 code: vec![],
1131 workflow: vec!["Tip Y".into()],
1132 };
1133 save_learnings_to_context_file(dir.path(), "claude-code", &learnings2).unwrap();
1134
1135 let content = std::fs::read_to_string(&claude_md).unwrap();
1136
1137 // Each heading should appear exactly once
1138 assert_eq!(
1139 content.matches("### Repo").count(),
1140 1,
1141 "### Repo duplicated:\n{}",
1142 content
1143 );
1144 assert_eq!(
1145 content.matches("### Workflow").count(),
1146 1,
1147 "### Workflow duplicated:\n{}",
1148 content
1149 );
1150 // All items present
1151 assert!(content.contains("- Learning A"));
1152 assert!(content.contains("- Learning B"));
1153 assert!(content.contains("- Tip X"));
1154 assert!(content.contains("- Tip Y"));
1155 }
1156
1157 #[test]
1158 fn test_save_code_learnings_excluded() {

Callers

nothing calls this directly

Calls 3

unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected