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

Function test_save_merge_into_existing_section

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

Source from the content-addressed store, hash-verified

1044
1045 #[test]
1046 fn test_save_merge_into_existing_section() {
1047 let dir = TempDir::new().unwrap();
1048 let claude_md = dir.path().join("CLAUDE.md");
1049
1050 // Write file with existing learnings section
1051 let existing = format!(
1052 "# Project\n\n{}\n\n{}\n\n{}\n\n### Repo\n- Existing learning\n\n{}\n",
1053 SECTION_HEADING, SECTION_NOTE, SECTION_START, SECTION_END
1054 );
1055 std::fs::write(&claude_md, &existing).unwrap();
1056
1057 let learnings = Learnings {
1058 repo: vec!["New learning".into()],
1059 code: vec![],
1060 workflow: vec![],
1061 };
1062
1063 let result = save_learnings_to_context_file(dir.path(), "claude-code", &learnings).unwrap();
1064
1065 assert_eq!(result.added, 1);
1066
1067 let content = std::fs::read_to_string(&claude_md).unwrap();
1068 assert!(content.contains("- Existing learning"));
1069 assert!(content.contains("- New learning"));
1070 // Should have only ONE ### Repo heading, not two
1071 assert_eq!(
1072 content.matches("### Repo").count(),
1073 1,
1074 "### Repo should appear exactly once, got:\n{}",
1075 content
1076 );
1077 }
1078
1079 #[test]
1080 fn test_save_dedup() {

Callers

nothing calls this directly

Calls 4

writeFunction · 0.85
unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected