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

Source from the content-addressed store, hash-verified

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