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:1113–1153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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