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

Function test_save_append_to_existing_file

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

Source from the content-addressed store, hash-verified

1013
1014 #[test]
1015 fn test_save_append_to_existing_file() {
1016 let dir = TempDir::new().unwrap();
1017 let claude_md = dir.path().join("CLAUDE.md");
1018
1019 // Write existing content
1020 std::fs::write(
1021 &claude_md,
1022 "# My Project\n\nExisting project documentation.\n",
1023 )
1024 .unwrap();
1025
1026 let learnings = Learnings {
1027 repo: vec!["New learning".into()],
1028 code: vec![],
1029 workflow: vec![],
1030 };
1031
1032 let result = save_learnings_to_context_file(dir.path(), "claude-code", &learnings).unwrap();
1033
1034 assert_eq!(result.added, 1);
1035
1036 let content = std::fs::read_to_string(&claude_md).unwrap();
1037 // Original content preserved
1038 assert!(content.contains("# My Project"));
1039 assert!(content.contains("Existing project documentation."));
1040 // New section appended
1041 assert!(content.contains(SECTION_HEADING));
1042 assert!(content.contains("- New learning"));
1043 }
1044
1045 #[test]
1046 fn test_save_merge_into_existing_section() {

Callers

nothing calls this directly

Calls 4

writeFunction · 0.85
unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected