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

Source from the content-addressed store, hash-verified

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